<html>
<head>
 <meta charset="UTF-8">
 <title>Postgresql集群管理器</title>
 <link rel="stylesheet" type="text/css" href="./themes/bootstrap/easyui.css">
 <link rel="stylesheet" type="text/css" href="./themes/icon.css">
 <link rel="stylesheet" type="text/css" href="./themes/color.css">
 <link rel="stylesheet" type="text/css" href="./themes/pgclusteradmin.css"> 
 <script type="text/javascript" src="./jquery.min.js"></script>
 <script type="text/javascript" src="./jquery.easyui.min.js"></script>
 <script type="text/javascript" src="./jquery.easyui.rule.js"></script> 
 <script type="text/javascript" src="./datagrid-detailview.js"></script>
 <script type="text/javascript" src="./locale/easyui-lang-zh_CN.js"></script>
</head>
<STYLE type=text/css>
.textbox-default-width{
  width: 268px;
}
.textbox-default-width-long{
  width: 705px;
}
.textbox-default-width-center{
  width: 405px;
}
.dialog-default-width{
  width: 900px;
}
</STYLE>
<body>


<div id='Loading' style="position:absolute;z-index:1000;top:0px;left:0px;width:100%;height:3000;background:#f2f2f2;text-align:center;padding-top: 20%;">
<h1><image src='./themes/default/images/loading.gif'/><font color="#15428B">加载中···</font></h1>
</div>


<table id="dg" class="easyui-datagrid">
 <thead data-options="frozen:true">    
   <tr>       
     <th field="id" checkbox="true"></th> 
     <th data-options="field:'node_name',sortable:true,width:'150px'">节点名称</th>
     <th data-options="field:'createtime',sortable:true,width:'200px'">建立时间</th> 
     <th data-options="field:'service_type',width:'80px'">节点类别</th>    
     <th data-options="field:'service_status',width:'80px'">运行状态</th>   
     <th data-options="field:'pg_version',width:'120px'">版本信息</th>   
   </tr>
 </thead>   
 <thead>
   <tr> 
     <th data-options="field:'host',width:'130px'">主机名或IP</th> 
     <th data-options="field:'ssh_port',width:'80px'">SSH端口号</th>
     <th data-options="field:'ssh_authmethod',width:'80px'">SSH认证方式</th>        
     <th data-options="field:'ssh_user',width:'100px'">SSH用户名</th> 
     <th data-options="field:'pg_bin',width:'200px'">PG服务端程序路径</th>
     <th data-options="field:'pg_data',width:'200px'">PGDATA所在路径</th>
     <th data-options="field:'pg_log',width:'200px'">访问日志保存路径</th>
     <th data-options="field:'pg_port',width:'80px'">PG服务端口号</th> 
     <th data-options="field:'pg_database',width:'100px'">连接数据库名称</th> 
     <th data-options="field:'pg_user',width:'100px'">数据库用户名称</th> 
     <th data-options="field:'master_vip',width:'100px'">做为主节点时绑定VIP</th>
     <th data-options="field:'master_vip_networkcard',width:'100px'">绑定VIP使用设备号</th> 
     <th data-options="field:'slave_vip',width:'100px'">做为备节点时绑定VIP</th>
     <th data-options="field:'slave_vip_networkcard',width:'100px'">绑定VIP使用设备号</th>
     <th data-options="field:'bind_vip_authmethod',width:'80px'">绑定网卡SSH认证方法</th>    
     <th data-options="field:'bind_vip_user',width:'100px'">绑定网卡操作用户</th>
     <th data-options="field:'remark',width:'200px'">备注</th>  
   </tr>
 </thead>
</table>

<div id="tb" style="height:auto">
  <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" id="cy_insert_click">增加节点</a>
  <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-edit',plain:true" id="cy_update_click">修改资料</a>
  <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true" id="cy_delete_click">删除节点</a>
  <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-parameter',plain:true" id="cy_parameter_click">参数配置</a>
  <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-service',plain:true" id="cy_serviceadmin_click">服务管理</a>
  <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-vip',plain:true" id="cy_vipadmin_click">VIP绑定</a> 
  <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-wakeup',plain:true" id="cy_slave_wakeup_click">备机唤醒</a>  
  <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-promote',plain:true" id="cy_promote_click">主备切换</a>  
  <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-report',plain:true" id="cy_inspection_report_click">巡检报告</a>
  <a href="javascript:void(0)" class="easyui-menubutton" data-options="iconCls:'icon-tools',plain:true,menu:'#cy_tools_menu'">管理工具</a>
  <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-password',plain:true" id="cy_password_click">修改登录密码</a>  
  <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-exit',plain:true" id="cy_exit_click">退出</a>  
</div>

<div id="cy_tools_menu" style="width:150px;">
  <div data-options="iconCls:'icon-process'" id="cy_processadmin_click">进程管理</div>
  <div data-options="iconCls:'icon-unlock'" id="cy_lockadmin_click">表锁管理</div>
  <div data-options="iconCls:'icon-count'" id="cy_querycount_click">查询统计</div>
</div>

<!--修改资料窗口-->
<div id="update_dialog" class="easyui-dialog dialog-default-width" data-options="modal:true,buttons:'#update_dialog_buttons',closed:true,height:618,closable:true"> <!--modal是遮罩层--> 
 <div style="padding:30px 5px 5px 10px">      
   <form id="update_dialog_form" method="post"> 
     <table cellpadding="3" width="99%">
        <tr>
          <td align="center" width="120">节点编号</td>
          <td><input class="easyui-textbox textbox-default-width" name="id" data-options="readonly:true,prompt:'系统自动编号'"/></td>
          <td align="center" width="120">节点名称</td>
          <td><input class="easyui-textbox textbox-default-width" name="node_name" data-options="required:true"/></td>
        </tr> 
        <tr>
          <td align="center" width="120">主机名或IP</td>
          <td><input class="easyui-textbox textbox-default-width" name="host" data-options="required:true" /></td>
          <td align="center" width="120">SSH端口号</td>
          <td><input class="easyui-numberbox textbox-default-width" name="ssh_port" data-options="required:true,min:1,precision:0"/></td>
        </tr>
        <tr>
          <td align="center" width="120">SSH认证方式</td>
          <td colspan="3"><select class="easyui-combobox textbox-default-width-long" name="ssh_authmethod" id="update_ssh_authmethod" data-options="editable:false,panelHeight:'auto',valueField: 'value',textField: 'label',data: [{label: '密钥登陆（key）',value: 'key',selected:true},{label: '密码登陆（password）',value: 'password'}]" required="true"></select></td> 
        </tr> 
        <tr>
          <td align="center">SSH用户名</td>
          <td><input class="easyui-textbox textbox-default-width" name="ssh_user" data-options="required:true"/></td>
          <td align="center">SSH登录密码</td>
          <td><input class="easyui-passwordbox textbox-default-width" name="ssh_password" id="update_ssh_password" iconWidth="28" data-options="required:false"/></td>
        </tr> 
        <tr>
          <td align="center" width="120">PG服务端程序路径</td>
          <td colspan="3"><input class="easyui-textbox  textbox-default-width-long" name="pg_bin" data-options="required:true"/></td> 
        </tr> 
        <tr>
          <td align="center" width="120">PGDATA所在路径</td>
          <td colspan="3"><select class="easyui-textbox  textbox-default-width-long" name="pg_data" data-options="required:true"/></td> 
        </tr>
        <tr>
          <td align="center" width="120">访问日志保存路径</td>
          <td colspan="3"><select class="easyui-textbox  textbox-default-width-long" name="pg_log" data-options="required:false"/></td> 
        </tr> 
        <tr>
          <td align="center">PG服务端口号</td>
          <td><input class="easyui-numberbox textbox-default-width" name="pg_port" data-options="required:true,min:1,precision:0"/></td>
          <td align="center">连接数据库名称</td>
          <td><input class="easyui-textbox textbox-default-width" name="pg_database" data-options="required:true"/></td>
        </tr> 
        <tr>
          <td align="center">数据库用户名称</td>
          <td><input class="easyui-textbox textbox-default-width" name="pg_user" data-options="required:true"/></td>
          <td align="center">数据库用户密码</td>
          <td><input class="easyui-passwordbox textbox-default-width" name="pg_password" id="update_pg_password" iconWidth="28" data-options="required:true"/></td>
        </tr> 
        <tr>
          <td align="center">做为主节点绑定VIP</td>
          <td><input class="easyui-textbox textbox-default-width" name="master_vip" data-options="required:false,validType:['isip']"/></td>
          <td align="center">VIP绑定设备号</td>
          <td><input class="easyui-textbox textbox-default-width" name="master_vip_networkcard" data-options="required:false,prompt:'如eth0:1'"/></td>
        </tr>  
        <tr>
          <td align="center">做为备节点绑定VIP</td>
          <td><input class="easyui-textbox textbox-default-width" name="slave_vip" data-options="required:false,validType:['isip']"/></td>
          <td align="center">VIP绑定设备号</td>
          <td><input class="easyui-textbox textbox-default-width" name="slave_vip_networkcard" data-options="required:false,prompt:'如eth0:1'"/></td>
        </tr>
        <tr>
          <td align="center" width="120">绑定网卡登录认证方式</td>
          <td colspan="3"><select class="easyui-combobox textbox-default-width-long" name="bind_vip_authmethod" id="update_bind_vip_authmethod" data-options="editable:false,panelHeight:'auto',valueField: 'value',textField: 'label',data: [{label: '密钥登陆（key）',value: 'key',selected:true},{label: '密码登陆（password）',value: 'password'}]" required="true"></select></td> 
        </tr> 
        <tr>
          <td align="center">绑定网卡操作用户</td>
          <td><input class="easyui-textbox textbox-default-width" name="bind_vip_user" data-options="required:false"/></td>
          <td align="center">绑定网卡操作密码</td>
          <td><input class="easyui-passwordbox textbox-default-width" name="bind_vip_password" id="update_bind_vip_password" iconWidth="28" data-options="required:false"/></td>
        </tr> 
        <tr>
          <td align="center" width="120">备注</td>
          <td colspan="3"><input class="easyui-textbox textbox-default-width-long" name="remark" data-options="multiline:true,height:60"  ></input></td> 
        </tr>          
     </table>         
   </form>
 </div>
</div>
<div id="update_dialog_buttons">
  <a href="javascript:void(0)" class="easyui-linkbutton c2" id="update_dialog_save" data-options="iconCls:'icon-save',width:80">保存</a>
  <a href="javascript:void(0)" class="easyui-linkbutton" id="update_dialog_cancel" data-options="iconCls:'icon-cancel',width:80">取消</a>
</div>                    
<!--修改资料窗口-->

<!--参数设置窗口-->
<div id="parameter_dialog" class="easyui-dialog dialog-default-width" data-options="modal:true,buttons:'#parameter_dialog_buttons',closed:true,height:688,closable:true,iconCls:'icon-parameter'"> <!--modal是遮罩层--> 
 <div style="padding:10px 5px 5px 5px">   
   <form id="parameter_dialog_form" method="post"> 
     <table cellpadding="3" width="99%">
       <tr>
         <td align="center" width="120">节点编号</td>
         <td><input class="easyui-textbox textbox-default-width" name="id" id="parameter_id" data-options="readonly:true,prompt:'系统自动编号'"/></td>
         <td align="center" width="120">节点名称</td>
         <td><input class="easyui-textbox textbox-default-width" name="node_name" data-options="readonly:true"/></td>
       </tr>
       <tr>
         <td align="center" width="120">节点类别</td>
         <td><input class="easyui-textbox textbox-default-width" name="service_type" id="parameter_service_type" data-options="readonly:true"/></td>
         <td align="center" width="120">运行状态</td>
         <td><input class="easyui-textbox textbox-default-width" name="service_status" id="parameter_service_status" data-options="readonly:true"/></td>
       </tr>
       <tr>
        <td align="center" width="120">版本号</td>
        <td colspan="3"><input class="easyui-textbox textbox-default-width-long" name="pg_version" id="parameter_pg_version" data-options="readonly:true"/></td> 
      </tr> 
      <tr>
        <td align="center" width="120">配置文件</td>    
        <td colspan="3"><select class="easyui-combobox textbox-default-width-long" name="parameter_files" id="parameter_files" data-options="editable:false,panelHeight:'auto',valueField: 'value',textField: 'label'" required="true"></select></td> 
      </tr>
      <tr>
        <td align="center" width="120">历史备份</td>    
        <td><select class="easyui-combogrid textbox-default-width" name="parameter_files_bak" id="parameter_files_bak" ></select></td>
        <td align="center" width="120">模板文件</td>
        <td><select class="easyui-combogrid textbox-default-width" name="parameter_files_template" id="parameter_files_template" ></select></td>
      </tr>
      <tr>
        <td align="center" width="120">文件内容</td>
        <td colspan="3"><input class="easyui-textbox textbox-default-width-long" name="parameter_file_contents" id="parameter_file_contents" data-options="readonly:false,multiline:true,height:290,required:true"></input></td> 
      </tr>
      <tr>
        <td align="center" width="120">备注</td>
        <td colspan="3"><input class="easyui-textbox textbox-default-width-long" name="remark" id="parameter_remark" data-options="readonly:false,required:true"/></td>
      </tr>  
      <tr>
        <td align="center" width="120">执行结果</td>
        <td colspan="3"><input class="easyui-textbox textbox-default-width-long" name="exec_result" id="parameter_exec_result" data-options="readonly:true,multiline:true,height:80"  ></input></td> 
      </tr>  
     </table>  
   </form>
 </div> 
</div>
<div id="parameter_dialog_buttons">  
  <a href="javascript:void(0)" class="easyui-linkbutton" id="parameter_dialog_save" data-options="iconCls:'icon-save',width:80">保存</a> 
  <a href="javascript:void(0)" class="easyui-linkbutton" id="parameter_dialog_reload" data-options="iconCls:'icon-reload',width:110">保存&reload</a>      
  <a href="javascript:void(0)" class="easyui-linkbutton" id="parameter_dialog_restart" data-options="iconCls:'icon-restart',width:110">保存&restart</a> 
  <a href="javascript:void(0)" class="easyui-linkbutton" id="parameter_dialog_saveas_template" data-options="iconCls:'icon-template',width:110">保存为模板</a>      
  <a href="javascript:void(0)" class="easyui-linkbutton" id="parameter_dialog_cancel" data-options="iconCls:'icon-cancel',width:80">取消</a>    
</div>   
<!--参数设置窗口-->

<!--服务管理窗口-->
<div id="serviceadmin_dialog" class="easyui-dialog dialog-default-width" data-options="modal:true,buttons:'#serviceadmin_dialog_buttons',closed:true,height:618,closable:true,iconCls:'icon-service'"> <!--modal是遮罩层--> 
 <div style="padding:30px 5px 5px 10px">      
   <form id="serviceadmin_dialog_form" method="post"> 
       <table cellpadding="3" width="99%">
          <tr>
            <td align="center" width="120">节点编号</td>
            <td><input class="easyui-textbox textbox-default-width" name="id" data-options="readonly:true,prompt:'系统自动编号'"/></td>
            <td align="center" width="120">节点名称</td>
            <td><input class="easyui-textbox textbox-default-width" name="node_name" data-options="readonly:true"/></td>
          </tr>
          <tr>
            <td align="center" width="120">节点类别</td>
            <td><input class="easyui-textbox textbox-default-width" name="service_type" id="service_type" data-options="readonly:true"/></td>
            <td align="center" width="120">运行状态</td>
            <td><input class="easyui-textbox textbox-default-width" name="service_status" id="service_status" data-options="readonly:true"/></td>
          </tr>
          <tr>
            <td align="center" width="120">版本号</td>
            <td colspan="3"><input class="easyui-textbox textbox-default-width-long" name="pg_version" id="pg_version" data-options="readonly:true"/></td> 
          </tr> 
          <tr>
            <td align="center" width="120">主机名或IP</td>
            <td><input class="easyui-textbox textbox-default-width" name="host" data-options="readonly:true" /></td>
            <td align="center" width="120">SSH端口号</td>
            <td><input class="easyui-numberbox textbox-default-width" name="ssh_port" data-options="readonly:true"/></td>
          </tr>
          <tr>
            <td align="center" width="120">SSH认证方式</td>
            <td colspan="3"><select class="easyui-combobox textbox-default-width-long" name="ssh_authmethod" data-options="readonly:true,editable:false,panelHeight:'auto',valueField: 'value',textField: 'label',data: [{label: '密钥登陆（key）',value: 'key',selected:true},{label: '密码登陆（password）',value: 'password'}]" required="true"></select></td> 
          </tr> 
          <tr>
            <td align="center">SSH用户名</td>
            <td><input class="easyui-textbox textbox-default-width" name="ssh_user" data-options="readonly:true"/></td>
            <td align="center">SSH登录密码</td>
            <td><input class="easyui-passwordbox textbox-default-width" name="ssh_password" iconWidth="28" data-options="readonly:false,required:false"/></td>
          </tr> 
          <tr>
            <td align="center" width="120">PG服务端程序路径</td>
            <td colspan="3"><input class="easyui-textbox textbox-default-width-long" name="pg_bin" id="pg_bin" data-options="readonly:true"/></td> 
          </tr> 
          <tr>
            <td align="center" width="120">PGDATA所在路径</td>
            <td colspan="3"><select class="easyui-textbox textbox-default-width-long" name="pg_data" id="pg_data" data-options="readonly:true"/></td> 
          </tr> 
          <tr>
            <td align="center" width="120">访问日志保存路径</td>
            <td colspan="3"><select class="easyui-textbox textbox-default-width-long" name="pg_log" id="pg_log" data-options="readonly:true"/></td> 
          </tr> 		
          <tr>
            <td align="center" width="120">关闭模式</td>
            <td colspan="3"><select class="easyui-combobox textbox-default-width-long" name="mode" id="mode" data-options="editable:false,panelHeight:'auto',valueField: 'value',textField: 'label',data: [{label: 'smart',value: 'smart'},{label: 'fast',value: 'fast',selected:true},{label: 'immediate',value: 'immediate'}]" required="true"></select></td> 
          </tr> 
          <tr>
            <td align="center" width="120">执行命令</td>
            <td colspan="3"><input class="easyui-textbox textbox-default-width-long" name="run_command" id="run_command" data-options="readonly:true,multiline:false"  ></input></td> 
          </tr> 
          <tr>
            <td align="center" width="120">执行结果</td>
            <td colspan="3"><input class="easyui-textbox textbox-default-width-long" name="exec_result" id="exec_result" data-options="readonly:true,multiline:true,height:120"  ></input></td> 
          </tr>          
       </table>         
   </form>
 </div>
</div>
<div id="serviceadmin_dialog_buttons">
  <a href="javascript:void(0)" class="easyui-linkbutton" id="serviceadmin_dialog_start" data-options="iconCls:'icon-start',width:80">start</a>
  <a href="javascript:void(0)" class="easyui-linkbutton" id="serviceadmin_dialog_stop" data-options="iconCls:'icon-stop',width:80">stop</a>
  <a href="javascript:void(0)" class="easyui-linkbutton" id="serviceadmin_dialog_restart" data-options="iconCls:'icon-restart',width:80">restart</a>   
  <a href="javascript:void(0)" class="easyui-linkbutton" id="serviceadmin_dialog_reload" data-options="iconCls:'icon-reload',width:80">reload</a>   
  <a href="javascript:void(0)" class="easyui-linkbutton" id="serviceadmin_dialog_status" data-options="iconCls:'icon-status',width:80">status</a>   
  <a href="javascript:void(0)" class="easyui-linkbutton" id="serviceadmin_dialog_cancel" data-options="iconCls:'icon-cancel',width:80">取消</a>    
</div>                    
<!--服务管理窗口-->     

<!--vip管理窗口-->
<div id="vipadmin_dialog" class="easyui-dialog dialog-default-width" data-options="modal:true,buttons:'#vipadmin_dialog_buttons',closed:true,height:668,closable:true,iconCls:'icon-vip'"> <!--modal是遮罩层--> 
 <div style="padding:8px 5px 5px 8px">      
   <form id="vipadmin_dialog_form" method="post"> 
       <table cellpadding="3" width="99%">
          <tr>
            <td align="center" width="120">节点编号</td>
            <td><input class="easyui-textbox textbox-default-width" name="id" id="vipadmin_id" data-options="readonly:true,prompt:'系统自动编号'"/></td>
            <td align="center" width="120">节点名称</td>
            <td><input class="easyui-textbox textbox-default-width" name="node_name" data-options="readonly:true"/></td>
          </tr>
          <tr>
            <td align="center" width="120">节点类别</td>
            <td><input class="easyui-textbox textbox-default-width" name="service_type" data-options="readonly:true"/></td>
            <td align="center" width="120">运行状态</td>
            <td><input class="easyui-textbox textbox-default-width" name="service_status" data-options="readonly:true"/></td>
          </tr>
          <tr>
            <td align="center" width="120">版本号</td>
            <td colspan="3"><input class="easyui-textbox textbox-default-width-long" name="pg_version" data-options="readonly:true"/></td> 
          </tr> 
          <tr>
            <td align="center" width="120">主机名或IP</td>
            <td><input class="easyui-textbox textbox-default-width" name="host" data-options="readonly:true" /></td>
            <td align="center" width="120">SSH端口号</td>
            <td><input class="easyui-numberbox textbox-default-width" name="ssh_port" data-options="readonly:true"/></td>
          </tr>
          <tr>
            <td align="center" width="120">PG服务端程序路径</td>
            <td colspan="3"><input class="easyui-textbox textbox-default-width-long" name="pg_bin" data-options="readonly:true"/></td> 
          </tr> 
          <tr>
            <td align="center" width="120">PGDATA所在路径</td>
            <td colspan="3"><select class="easyui-textbox textbox-default-width-long" name="pg_data" data-options="readonly:true"/></td> 
          </tr>  
          <tr>
            <td align="center">VIP地址</td>
            <td><input class="easyui-textbox textbox-default-width" name="vip" data-options="readonly:false,required:true,validType:['isip']"/></td>
            <td align="center">网卡设备号</td>
            <td><input class="easyui-textbox textbox-default-width" name="vip_networkcard" data-options="readonly:false,required:true,prompt:'如eth0:1'"/></td>
          </tr>
          <tr>
            <td align="center" width="120">绑定网卡登录认证方式</td>
            <td colspan="3"><select class="easyui-combobox textbox-default-width-long" name="bind_vip_authmethod" id="vipadmin_bind_vip_authmethod" data-options="editable:false,panelHeight:'auto',valueField: 'value',textField: 'label',data: [{label: '密钥登陆（key）',value: 'key',selected:true},{label: '密码登陆（password）',value: 'password'}]" required="true"></select></td> 
          </tr> 
          <tr>
            <td align="center">绑定操作用户名</td>
            <td><input class="easyui-textbox textbox-default-width" name="bind_vip_user" id="vipadmin_bind_vip_user" data-options="readonly:false,required:true"/></td>
            <td align="center">操作用户密码</td>
            <td><input class="easyui-passwordbox textbox-default-width" name="bind_vip_password" id="vipadmin_bind_vip_password" iconWidth="28" data-options="readonly:false,required:true"/></td>
          </tr> 
          <tr>
            <td align="center" width="120">IP绑定详情</td>
            <td colspan="3"><input class="easyui-textbox textbox-default-width-long" name="vipadmin_ip_status" id="vipadmin_ip_status" data-options="readonly:true,multiline:true,height:160"  ></input></td> 
          </tr> 
          <tr>
            <td align="center" width="120">执行结果</td>
            <td colspan="3"><input class="easyui-textbox textbox-default-width-long" name="vipadmin_exec_result" id="vipadmin_exec_result" data-options="readonly:true,multiline:true,height:50"  ></input></td> 
          </tr>   
          <tr>
             <td align="center" width="120">操作说明</td>
             <td colspan="3">填写要解绑或绑定IP和对应的网卡设备号,再按"绑定VIP"或"解绑VIP"即可.Linnx下绑定vip一般需要root权限,不清楚网卡设备号请询问SA,千万不能乱操作</td> 
           </tr>         
       </table>         
   </form>
 </div>
</div>
<div id="vipadmin_dialog_buttons">
  <a href="javascript:void(0)" class="easyui-linkbutton" id="vipadmin_dialog_bind" data-options="iconCls:'icon-vip',width:80">绑定VIP</a>   
  <a href="javascript:void(0)" class="easyui-linkbutton" id="vipadmin_dialog_unbind" data-options="iconCls:'icon-vip-unbind',width:80">解绑VIP</a>   
  <a href="javascript:void(0)" class="easyui-linkbutton" id="vipadmin_dialog_ip_refresh" data-options="iconCls:'icon-refresh',width:120">刷新ip绑定详情</a>           
  <a href="javascript:void(0)" class="easyui-linkbutton" id="vipadmin_dialog_cancel" data-options="iconCls:'icon-cancel',width:80">取消</a>    
</div>                    
<!--vip管理窗口-->   

<!--备机唤醒管理窗口-->
<div id="slave_wakeup_dialog" class="easyui-dialog dialog-default-width" data-options="modal:true,buttons:'#slave_wakeup_dialog_buttons',closed:true,height:688,closable:true,iconCls:'icon-wakeup'"> <!--modal是遮罩层--> 
 <div style="padding:8px 5px 5px 8px">      
   <form id="slave_wakeup_dialog_form" method="post"> 
       <table cellpadding="3" width="99%">
          <tr>
            <td align="center" width="120">节点编号</td>
            <td><input class="easyui-textbox textbox-default-width" name="id" id="slave_wakeup_id" data-options="readonly:true,prompt:'系统自动编号'"/></td>
            <td align="center" width="120">节点名称</td>
            <td><input class="easyui-textbox textbox-default-width" name="node_name" data-options="readonly:true"/></td>
          </tr>
          <tr>
            <td align="center" width="120">节点类别</td>
            <td><input class="easyui-textbox textbox-default-width" name="service_type" id="wakeup_service_type" data-options="readonly:true"/></td>
            <td align="center" width="120">运行状态</td>
            <td><input class="easyui-textbox textbox-default-width" name="service_status" data-options="readonly:true"/></td>
          </tr>
          <tr>
            <td align="center" width="120">版本号</td>
            <td colspan="3"><input class="easyui-textbox textbox-default-width-long" name="pg_version" data-options="readonly:true"/></td> 
          </tr> 
          <tr>
            <td align="center" width="120">主机名或IP</td>
            <td><input class="easyui-textbox textbox-default-width" name="host" data-options="readonly:true" /></td>
            <td align="center" width="120">SSH端口号</td>
            <td><input class="easyui-numberbox textbox-default-width" name="ssh_port" data-options="readonly:true"/></td>
          </tr>     
          <tr>
            <td align="center" width="120">PG服务端程序路径</td>
            <td colspan="3"><input class="easyui-textbox textbox-default-width-long" name="pg_bin" data-options="readonly:true"/></td> 
          </tr> 
          <tr>
            <td align="center" width="120">PGDATA所在路径</td>
            <td colspan="3"><select class="easyui-textbox textbox-default-width-long" name="pg_data" data-options="readonly:true"/></td> 
          </tr>    
          <tr>
            <td align="center">唤醒后绑定VIP地址</td>
            <td><input class="easyui-textbox textbox-default-width" name="vip" id="salve_makeup_vip" data-options="readonly:false,required:false,validType:['isip']"/></td>
            <td align="center">绑定网卡设备号</td>
            <td><input class="easyui-textbox textbox-default-width" name="vip_networkcard" data-options="readonly:false,required:false,prompt:'如eth0:1'"/></td>
          </tr>
          <tr>
            <td align="center" width="120">绑定网卡登录认证方式</td>
            <td colspan="3"><select class="easyui-combobox textbox-default-width-long" name="bind_vip_authmethod" id="slave_wakeup_bind_vip_authmethod" data-options="editable:false,panelHeight:'auto',valueField: 'value',textField: 'label',data: [{label: '密钥登陆（key）',value: 'key',selected:true},{label: '密码登陆（password）',value: 'password'}]" required="true"></select></td> 
          </tr> 
          <tr>
            <td align="center">绑定操作用户名</td>
            <td><input class="easyui-textbox textbox-default-width" name="bind_vip_user" id="slave_wakeup_bind_vip_user" data-options="readonly:false,required:false"/></td>
            <td align="center">操作用户密码</td>
            <td><input class="easyui-passwordbox textbox-default-width" name="bind_vip_password" id="slave_wakeup_bind_vip_password" iconWidth="28" data-options="readonly:false,required:false"/></td>
          </tr> 
          <tr>
            <td align="center">唤醒后执行VACUUM</td>
            <td colspan="3"><input class="easyui-switchbutton" name="vacuum_check" id="vacuum_check" data-options="checked:true,value:1"></td>
          </tr> 
          <tr>
            <td align="center" width="120">IP绑定详情</td>
            <td colspan="3"><input class="easyui-textbox textbox-default-width-long" name="slave_wakeup_ip_status" id="slave_wakeup_ip_status" data-options="readonly:true,multiline:true,height:160"  ></input></td> 
          </tr> 
          <tr>
            <td align="center" width="120">执行结果</td>
            <td colspan="3"><input class="easyui-textbox textbox-default-width-long" name="slave_wakeup_exec_result" id="slave_wakeup_exec_result" data-options="readonly:true,multiline:true,height:50"  ></input></td> 
          </tr>   
          <tr>
             <td align="center" width="120">操作说明</td>
             <td colspan="3">备机唤醒后,如果节点为同步复制模式并且没备机连接上来,则系统会修改运行参数把节点的同步模式修改为异步模式.</td> 
          </tr>         
       </table>         
   </form>
 </div>
</div>
<div id="slave_wakeup_dialog_buttons">
  <a href="javascript:void(0)" class="easyui-linkbutton c5" id="slave_wakeup_dialog_run" data-options="iconCls:'icon-run',width:80">执行</a>   
  <a href="javascript:void(0)" class="easyui-linkbutton" id="slave_wakeup_dialog_ip_refresh" data-options="iconCls:'icon-refresh',width:120">刷新ip绑定详情</a>           
  <a href="javascript:void(0)" class="easyui-linkbutton" id="slave_wakeup_dialog_cancel" data-options="iconCls:'icon-cancel',width:80">取消</a>    
</div>                    
<!--备机唤醒管理窗口-->

<!--主备切换窗口-->
<div id="promote_dialog" class="easyui-dialog dialog-default-width" data-options="modal:true,buttons:'#promote_dialog_buttons',closed:true,height:688,closable:true,iconCls:'icon-promote'"> <!--modal是遮罩层--> 
   <form id="promote_dialog_form" method="post"> 
     <div class="easyui-tabs" id="promote_tabs" fit="true" style="width:100%;height:600px"> 
       <div title="主节点（master）" style="padding:10px">
         <table cellpadding="3" width="99%">
           <tr>
             <td align="center" width="120">节点编号</td>
             <td><input class="easyui-textbox textbox-default-width" name="master_id" id="promote_master_id" data-options="readonly:true,prompt:'系统自动编号'"/></td>
             <td align="center" width="120">节点名称</td>
             <td><input class="easyui-textbox textbox-default-width" name="master_node_name" data-options="readonly:true"/></td>
           </tr>
           <tr>
             <td align="center" width="120">节点类别</td>
             <td><input class="easyui-textbox textbox-default-width" name="master_service_type" data-options="readonly:true"/></td>
             <td align="center" width="120">运行状态</td>
             <td><input class="easyui-textbox textbox-default-width" name="master_service_status" data-options="readonly:true"/></td>
           </tr>
           <tr>
             <td align="center" width="120">版本号</td>
             <td colspan="3"><input class="easyui-textbox textbox-default-width-long" name="master_pg_version" data-options="readonly:true"/></td> 
           </tr> 
           <tr>
             <td align="center" width="120">主机名或IP</td>
             <td><input class="easyui-textbox textbox-default-width" name="master_host" data-options="readonly:true" /></td>
             <td align="center" width="120">SSH端口号</td>
             <td><input class="easyui-numberbox textbox-default-width" name="master_ssh_port" data-options="readonly:true"/></td>
           </tr>
           <tr>
            <td align="center" width="120">SSH认证方式</td>
            <td colspan="3"><select class="easyui-combobox textbox-default-width-long" name="master_ssh_authmethod" data-options="readonly:true,editable:false,panelHeight:'auto',valueField: 'value',textField: 'label',data: [{label: '密钥登陆（key）',value: 'key',selected:true},{label: '密码登陆（password）',value: 'password'}]" required="true"></select></td> 
           </tr> 
           <tr>
             <td align="center">SSH用户名</td>
             <td><input class="easyui-textbox textbox-default-width" name="master_ssh_user" data-options="readonly:true"/></td>
             <td align="center">SSH登录密码</td>
             <td><input class="easyui-passwordbox textbox-default-width" name="master_ssh_password" data-options="readonly:false"/></td>
           </tr> 
           <tr>
             <td align="center" width="120">PG服务端程序路径</td>
             <td colspan="3"><input class="easyui-textbox textbox-default-width-long" name="master_pg_bin" id="master_pg_bin" data-options="readonly:true"/></td> 
           </tr> 
           <tr>
             <td align="center" width="120">PGDATA所在路径</td>
             <td colspan="3"><select class="easyui-textbox textbox-default-width-long" name="master_pg_data" id="master_pg_data" data-options="readonly:true"/></td> 
           </tr> 
           <tr>
             <td align="center">PG服务端口号</td>
             <td><input class="easyui-numberbox textbox-default-width" name="master_pg_port" data-options="readonly:true"/></td>
             <td align="center">连接数据库名称</td>
             <td><input class="easyui-textbox textbox-default-width" name="master_pg_database" data-options="readonly:true"/></td>
           </tr> 
           <tr>
             <td align="center">数据库用户名称</td>
             <td><input class="easyui-textbox textbox-default-width" name="master_pg_user" data-options="readonly:true"/></td>
             <td align="center">数据库用户密码</td>
             <td><input class="easyui-passwordbox textbox-default-width" name="master_pg_password" data-options="readonly:false"/></td>
           </tr>  
           <tr>
             <td align="center" width="120">IP绑定详情</td>
             <td colspan="3"><input class="easyui-textbox textbox-default-width-long" name="master_ip_status" id="master_ip_status" data-options="readonly:true,multiline:true,height:210"></input></td> 
           </tr>   
         </table> 
       </div>
       <div title="备节点（slave）" style="padding:10px">
         <table cellpadding="3" width="99%">
           <tr>
             <td align="center" width="120">节点编号</td>
             <td><input class="easyui-textbox textbox-default-width" name="slave_id" id="promote_slave_id" data-options="readonly:true,prompt:'系统自动编号'"/></td>
             <td align="center" width="120">节点名称</td>
             <td><input class="easyui-textbox textbox-default-width" name="slave_node_name" data-options="readonly:true"/></td>
           </tr>
           <tr>
             <td align="center" width="120">节点类别</td>
             <td><input class="easyui-textbox textbox-default-width" name="slave_service_type" data-options="readonly:true"/></td>
             <td align="center" width="120">运行状态</td>
             <td><input class="easyui-textbox textbox-default-width" name="slave_service_status" data-options="readonly:true"/></td>
           </tr>
           <tr>
             <td align="center" width="120">版本号</td>
             <td colspan="3"><input class="easyui-textbox textbox-default-width-long" name="slave_pg_version" data-options="readonly:true"/></td> 
           </tr> 
           <tr>
             <td align="center" width="120">主机名或IP</td>
             <td><input class="easyui-textbox textbox-default-width" name="slave_host" data-options="readonly:true" /></td>
             <td align="center" width="120">SSH端口号</td>
             <td><input class="easyui-numberbox textbox-default-width" name="slave_ssh_port" data-options="readonly:true"/></td>
           </tr>
           <tr>
            <td align="center" width="120">SSH认证方式</td>
            <td colspan="3"><select class="easyui-combobox textbox-default-width-long" name="slave_ssh_authmethod" data-options="readonly:true,editable:false,panelHeight:'auto',valueField: 'value',textField: 'label',data: [{label: '密钥登陆（key）',value: 'key',selected:true},{label: '密码登陆（password）',value: 'password'}]" required="true"></select></td> 
           </tr>  
           <tr>
             <td align="center">SSH用户名</td>
             <td><input class="easyui-textbox textbox-default-width" name="slave_ssh_user" data-options="readonly:true"/></td>
             <td align="center">SSH登录密码</td>
             <td><input class="easyui-passwordbox textbox-default-width" name="slave_ssh_password" data-options="readonly:false"/></td>
           </tr> 
           <tr>
             <td align="center" width="120">PG服务端程序路径</td>
             <td colspan="3"><input class="easyui-textbox textbox-default-width-long" name="slave_pg_bin" id="slave_pg_bin" data-options="readonly:true"/></td> 
           </tr> 
           <tr>
             <td align="center" width="120">PGDATA所在路径</td>
             <td colspan="3"><select class="easyui-textbox textbox-default-width-long" name="slave_pg_data" id="slave_pg_data" data-options="readonly:true"/></td> 
           </tr>
           <tr>
             <td align="center">PG服务端口号</td>
             <td><input class="easyui-numberbox textbox-default-width" name="slave_pg_port" data-options="readonly:true"/></td>
             <td align="center">连接数据库名称</td>
             <td><input class="easyui-textbox textbox-default-width" name="slave_pg_database" data-options="readonly:true"/></td>
           </tr> 
           <tr>
             <td align="center">数据库用户名称</td>
             <td><input class="easyui-textbox textbox-default-width" name="slave_pg_user" data-options="readonly:true"/></td>
             <td align="center">数据库用户密码</td>
             <td><input class="easyui-passwordbox textbox-default-width" name="slave_pg_password" data-options="readonly:false"/></td>
           </tr>  
           <tr>
             <td align="center" width="120">IP绑定详情</td>
             <td colspan="3"><input class="easyui-textbox textbox-default-width-long" name="slave_ip_status" id="slave_ip_status" data-options="readonly:true,multiline:true,height:210"></input></td> 
           </tr>  
         </table>  
       </div>
       <div title="切换参数配置" style="padding:10px">
         <table cellpadding="3" width="99%">  
           <tr>
             <td align="center" width="120">复制参数（recovery.conf）</td>
             <td colspan="3"><input class="easyui-textbox textbox-default-width-long" name="recovery_conf" data-options="readonly:false,required:true,multiline:true,height:90"></input></td> 
           </tr>  
           <tr>
             <td align="center" width="120">主节点切为备节点参数</td> 
             <td colspan="3" height="20"><div class="datagrid-toolbar c6"></div></td>
           </tr>     
           <tr>
             <td align="center" width="120">切换前解绑vip</td>
             <td><input class="easyui-textbox textbox-default-width" name="master_unbind_vip" id="master_unbind_vip" data-options="required:false,validType:['isip','bind_unbind_vip_equal[\'#master_bind_vip\']','master_slave_vip_equal[\'#slave_unbind_vip\']']"/></td>
             <td align="center" width="120">解绑网卡设备号</td>
             <td><input class="easyui-textbox textbox-default-width" name="master_unbind_vip_networkcard" id="master_unbind_vip_networkcard" data-options="required:false,readonly:false,prompt:'如eth0'"/></td>
           </tr>
           <tr>
             <td align="center" width="120">切换后绑定vip</td>
             <td><input class="easyui-textbox textbox-default-width" name="master_bind_vip" id="master_bind_vip" data-options="required:false,validType:['isip','bind_unbind_vip_equal[\'#master_unbind_vip\']','master_slave_vip_equal[\'#slave_bind_vip\']']"/></td>
             <td align="center" width="120">绑定网卡设备号</td>
             <td><input class="easyui-textbox textbox-default-width" name="master_bind_vip_networkcard" id="master_bind_vip_networkcard" data-options="required:false,readonly:false,prompt:'如eth0'"/></td>
           </tr>
           <tr>
             <td align="center" width="120">绑定网卡登录认证方式</td>
             <td colspan="3"><select class="easyui-combobox textbox-default-width-long" name="master_bind_vip_authmethod" id="master_bind_vip_authmethod" data-options="editable:false,panelHeight:'auto',valueField: 'value',textField: 'label',data: [{label: '密钥登陆（key）',value: 'key',selected:true},{label: '密码登陆（password）',value: 'password'}]" required="true"></select></td> 
           </tr> 
           <tr>
             <td align="center" width="120">绑定操作用户</td>
             <td><input class="easyui-textbox textbox-default-width" name="master_bind_user" id="master_bind_user" data-options="required:false,prompt:'一般只有root有绑定vip的权限'"/></td>
             <td align="center" width="120">操作用户密码</td>
             <td><input class="easyui-passwordbox textbox-default-width" name="master_bind_password" id="master_bind_password" data-options="readonly:false"/></td>
           </tr>
           <tr>
             <td align="center" width="120">备节点切为主节点参数</td> 
             <td colspan="3" height="20"><div class="datagrid-toolbar c6"></div></td>
           </tr>       
           <tr>
             <td align="center" width="120">切换前解绑vip</td>
             <td><input class="easyui-textbox textbox-default-width" name="slave_unbind_vip" id="slave_unbind_vip" data-options="required:false,validType:['isip','bind_unbind_vip_equal[\'#slave_bind_vip\']','master_slave_vip_equal[\'#master_unbind_vip\']']"/></td>
             <td align="center" width="120">解绑网卡设备号</td>
             <td><input class="easyui-textbox textbox-default-width" name="slave_unbind_vip_networkcard" id="slave_unbind_vip_networkcard" data-options="required:false,readonly:false,prompt:'如eth0:1'"/></td>
           </tr>
           <tr>
             <td align="center" width="120">切换后绑定vip</td>
             <td><input class="easyui-textbox textbox-default-width" name="slave_bind_vip" id="slave_bind_vip" data-options="required:false,validType:['isip','bind_unbind_vip_equal[\'#slave_unbind_vip\']','master_slave_vip_equal[\'#master_bind_vip\']']"/></td>
             <td align="center" width="120">绑定网卡设备号</td>
             <td><input class="easyui-textbox textbox-default-width" name="slave_bind_vip_networkcard" id="slave_bind_vip_networkcard" data-options="required:false,readonly:false,prompt:'如eth0:1'"/></td>
           </tr>
           <tr>
             <td align="center" width="120">绑定网卡登录认证方式</td>
             <td colspan="3"><select class="easyui-combobox textbox-default-width-long" name="slave_bind_vip_authmethod" id="slave_bind_vip_authmethod" data-options="editable:false,panelHeight:'auto',valueField: 'value',textField: 'label',data: [{label: '密钥登陆（key）',value: 'key',selected:true},{label: '密码登陆（password）',value: 'password'}]" required="true"></select></td> 
           </tr> 
           <tr>
             <td align="center" width="120">绑定操作用户</td>
             <td><input class="easyui-textbox textbox-default-width" name="slave_bind_user" id="slave_bind_user" data-options="required:false,prompt:'一般只有root有绑定vip的权限'"/></td>
             <td align="center" width="120">操作用户密码</td>
             <td><input class="easyui-passwordbox textbox-default-width" name="slave_bind_password" id="slave_bind_password" data-options="readonly:false"/></td>
           </tr> 
           <tr>
             <td colspan="4" height="10"></td>
           </tr>
           <tr>
             <td align="center" width="120">执行结果</td>
             <td colspan="3"><input class="easyui-textbox textbox-default-width-long" name="promote_exec_result" id="promote_exec_result" data-options="readonly:true,multiline:true,height:80"></input></td> 
           </tr> 
           <tr>
             <td colspan="4" height="10"></td>
           </tr>
           <tr>
             <td align="center" width="120">切换说明</td>
             <td colspan="3">除复制参数（recovery.conf）外，vip绑定视需要填写，不填写不执行vip绑定功能，Linnx下绑定vip一般需要root权限。</td> 
           </tr>          
         </table>  
       </div>
     </div>                   
   </form>  
</div>
<div id="promote_dialog_buttons">
  <a href="javascript:void(0)" class="easyui-linkbutton c5" id="promote_dialog_start" data-options="iconCls:'icon-promote',width:100">一键切换</a>  
  <a href="javascript:void(0)" class="easyui-linkbutton" id="promote_dialog_ip_refresh" data-options="iconCls:'icon-refresh',width:120">刷新ip绑定详情</a>      
  <a href="javascript:void(0)" class="easyui-linkbutton" id="promote_dialog_cancel" data-options="iconCls:'icon-cancel',width:80">取消</a>    
</div>                    
<!--主务切换窗口-->

<!--巡检报告管理窗口-->
<div id="inspection_report_dialog" class="easyui-dialog" data-options="modal:true,buttons:'#inspection_report_dialog_button',closed:true,width:1250,height:550,resizable:true,closable:true,maximizable:true,iconCls:'icon-report'"> <!--modal是遮罩层--> 
 <div class="easyui-layout" fit="true"> 
   <div region="west" split="true" style="width:400px;border-right:0px dotted #ccc;border-left:0px;border-top:0px;border-bottom:0px">
     <table id="inspection_report_list" class="easyui-datagrid">   
      <thead>
        <tr>
          <th field="id" checkbox="true"></th>
          <th data-options="field:'report_name',sortable:true,width:'130px'">报告名称</th> 
          <th data-options="field:'createtime',sortable:true,width:'100px'">生成时间</th>
		  <th data-options="field:'count_finish',sortable:true,width:'100px'">统计已完成</th>
          <th data-options="field:'username',sortable:true,width:'80px'">操作员账号</th>        
        </tr>
      </thead>
     </table> 
   </div> 
   <div region="center" border="false" >   
     <div class="easyui-tabs" id="inspection_report_tabs" fit="true" style="width:100%;height:600px">
       <div title="状态统计" style="padding:0px">
         <table id="inspection_report_state_list" class="easyui-datagrid">   
           <thead>
             <tr>
               <th data-options="field:'id',sortable:true,width:'80px'">ID号</th>			
               <th data-options="field:'subject',sortable:true,width:'280px'">项目</th> 
               <th data-options="field:'val',sortable:true,width:'680px'">值</th> 
             </tr>
           </thead>
         </table>
       </div>
       <div title="表空间" style="padding:0px"> 
         <table id="inspection_report_tablespace_list" class="easyui-datagrid">   
           <thead>
             <tr>
               <th data-options="field:'spcname',sortable:true,width:'130px'">表空间名称</th> 
               <th data-options="field:'spccomment',sortable:true,width:'130px'">注释</th> 
               <th data-options="field:'spcowner',sortable:true,width:'100px'">所有者</th>
               <th data-options="field:'location',sortable:true,width:'280px'">路径</th>        
               <th data-options="field:'spcsize',sortable:true,width:'80px'">占用空间</th>        
               <th data-options="field:'tablenum',sortable:true,width:'80px',align:'right'">数据表数</th>        
               <th data-options="field:'indexnum',sortable:true,width:'80px',align:'right'">索引数</th>        									
             </tr>
           </thead>
         </table>
       </div>
       <div title="角色" style="padding:0px"> 
         <table id="inspection_report_role_list" class="easyui-datagrid">   
           <thead>
             <tr>
               <th data-options="field:'rolname',sortable:true,width:'130px'">用户名</th>
               <th data-options="field:'rolcomment',sortable:true,width:'130px',align:'center'">注释</th>			
               <th data-options="field:'rolsuper',sortable:true,width:'70px',align:'center'">超级用户</th>
               <th data-options="field:'rolcreaterole',sortable:true,width:'85px',align:'center'">准许创建用户</th>
               <th data-options="field:'rolcreatedb',sortable:true,width:'95px',align:'center'">准许创建数据库</th>
               <th data-options="field:'rolcanlogin',sortable:true,width:'70px',align:'center'">准许登录</th>
               <th data-options="field:'rolreplication',sortable:true,width:'70px',align:'center'">复制角色</th>
               <th data-options="field:'rolconnlimit',sortable:true,width:'80px',align:'right'">并发连接数</th>
               <th data-options="field:'rolpassword_state',sortable:true,width:'70px'">口令状态</th>
               <th data-options="field:'rolvaliduntil',sortable:true,width:'130px'">口令过期时间</th>
               <th data-options="field:'datnum',sortable:true,width:'130px',align:'right'">数据库数</th>
               <th data-options="field:'tablenum',sortable:true,width:'130px',align:'right'">数据表数</th>
               <th data-options="field:'indexnum',sortable:true,width:'130px',align:'right'">索引数</th>									
             </tr>
           </thead>
         </table> 
       </div>
       <div title="数据库" style="padding:0px"> 
         <table id="inspection_report_database_list" class="easyui-datagrid">   
           <thead>
             <tr>
               <th data-options="field:'datname',sortable:true,width:'130px'">数据库名</th> 
               <th data-options="field:'datcomment',sortable:true,width:'130px'">注释</th> 
               <th data-options="field:'datdba',sortable:true,width:'70px',align:'center'">所有者</th>
               <th data-options="field:'encoding',sortable:true,width:'70px',align:'center'">默认编码</th>
               <th data-options="field:'datcollate',sortable:true,width:'70px',align:'center'">排序规则</th>
               <th data-options="field:'datctype',sortable:true,width:'70px',align:'center'">分组规则</th>
               <th data-options="field:'datistemplate',sortable:true,width:'75px',align:'center'">模板数据库</th>
               <th data-options="field:'datallowconn',sortable:true,width:'70px',align:'center'">准许连接</th>
               <th data-options="field:'datconnlimit',sortable:true,width:'75px',align:'right'">最大连接数</th>
               <th data-options="field:'dattablespace',sortable:true,width:'100px'">默认表空间</th>
               <th data-options="field:'datsize',sortable:true,width:'100px'">占用空间</th>
               <th data-options="field:'tablenum',sortable:true,width:'100px',align:'right'">数据表数</th>
               <th data-options="field:'indexnum',sortable:true,width:'100px',align:'right'">索引数</th>									
             </tr>
           </thead>
         </table> 
       </div>
       <div title="数据表" style="padding:0px"> 
         <table id="inspection_report_table_list" class="easyui-datagrid">   
           <thead>
             <tr>
               <th data-options="field:'datname',sortable:true,width:'130px'">数据库名</th> 
               <th data-options="field:'schemaname',sortable:true,width:'130px'">所属模式</th> 
               <th data-options="field:'tablename',sortable:true,width:'150px',align:'left'">表名</th>
               <th data-options="field:'tabletype',sortable:true,width:'80px',align:'left'">表类型</th>
               <th data-options="field:'tablecomment',sortable:true,width:'150px',align:'left'">注释</th>
               <th data-options="field:'tableowner',sortable:true,width:'70px',align:'left'">所有者</th>
               <th data-options="field:'tablespace',sortable:true,width:'80px',align:'center'">存储表空间</th>
               <th data-options="field:'reltuples',sortable:true,width:'100px',align:'right'">记录数（估值）</th>
               <th data-options="field:'rownum',sortable:true,width:'75px',align:'right'">记录数</th>
               <th data-options="field:'rownum_deviation',sortable:true,width:'75px',align:'right'">记录数差异</th>
               <th data-options="field:'relationsize',sortable:true,width:'100px',align:'left'">表文件占用空间</th>
               <th data-options="field:'relpages',sortable:true,width:'100px',align:'right'">占用盘页（估值）</th>
               <th data-options="field:'row_of_size',sortable:true,width:'100px',align:'left'">每行占用空间</th>
               <th data-options="field:'indexnum',sortable:true,width:'75px',align:'right'">索引数</th>
               <th data-options="field:'indexsize',sortable:true,width:'120px',align:'left'">索引文件占用空间</th>
               <th data-options="field:'tablesize',sortable:true,width:'120px',align:'left'">表相关文件占用空间</th>	
               <th data-options="field:'seq_scan',sortable:true,width:'100px',align:'right'">顺序扫描次数</th>
               <th data-options="field:'seq_tup_read',sortable:true,width:'130px',align:'right'">顺序扫描取得行数</th>
               <th data-options="field:'idx_scan',sortable:true,width:'100px',align:'right'">索引扫描次数</th>
               <th data-options="field:'idx_tup_fetch',sortable:true,width:'130px',align:'right'">索引扫描取得行数</th>
               <th data-options="field:'last_vacuum',sortable:true,width:'130px'">手动清理时间</th>
               <th data-options="field:'last_autovacuum',sortable:true,width:'130px'">自动清理时间</th>
               <th data-options="field:'last_analyze',sortable:true,width:'130px'">手动分析时间</th>
               <th data-options="field:'last_autoanalyze',sortable:true,width:'130px'">自动分析时间</th>
             </tr>
           </thead>
         </table> 
       </div>
       <div title="外部表" style="padding:0px"> 
         <table id="inspection_report_foreign_table_list" class="easyui-datagrid">   
           <thead>
             <tr>
               <th data-options="field:'datname',sortable:true,width:'130px'">数据库名</th> 
               <th data-options="field:'schemaname',sortable:true,width:'130px'">所属模式</th> 
               <th data-options="field:'tablename',sortable:true,width:'150px',align:'left'">表名</th>
               <th data-options="field:'srvname',sortable:true,width:'150px',align:'left'">外部服务器名称</th>
               <th data-options="field:'srvoptions',sortable:true,width:'350px',align:'left'">外部服务器配置</th>
               <th data-options="field:'ftoptions',sortable:true,width:'350px',align:'left'">外部表名称</th>
               <th data-options="field:'tablecomment',sortable:true,width:'150px',align:'left'">注释</th>
               <th data-options="field:'tableowner',sortable:true,width:'70px',align:'left'">所有者</th>
             </tr>
           </thead>
         </table> 
       </div>
       <div title="索引" style="padding:0px"> 
         <table id="inspection_report_index_list" class="easyui-datagrid">   
           <thead>
             <tr>
               <th data-options="field:'datname',sortable:true,width:'130px'">数据库名</th> 
               <th data-options="field:'schemaname',sortable:true,width:'130px'">所属模式</th> 
               <th data-options="field:'tablename',sortable:true,width:'150px',align:'left'">表名</th>
               <th data-options="field:'indexname',sortable:true,width:'350px',align:'left'">索引名</th>
               <th data-options="field:'indexcomment',sortable:true,width:'150px',align:'left'">注释</th>
               <th data-options="field:'indexowner',sortable:true,width:'80px',align:'left'">所有者</th>
               <th data-options="field:'uniqueindex',sortable:true,width:'75px',align:'center'">唯一索引</th>
               <th data-options="field:'indexsize',sortable:true,width:'100px',align:'left'">占用空间</th>
               <th data-options="field:'tablespace',sortable:true,width:'90px',align:'left'">存储表空间</th>
               <th data-options="field:'idx_scan',sortable:true,width:'120px',align:'right'">索引扫描次数</th>
               <th data-options="field:'indexdef',sortable:true,width:'1000px',align:'left'">索引定义</th> 
             </tr>
           </thead>
         </table> 
       </div>
     </div>
   </div>
 </div> 
</div> 
<div id="inspection_report_dialog_button">
  <a href="javascript:void(0)" class="easyui-linkbutton c5" id="inspection_report_dialog_insert" data-options="iconCls:'icon-add',width:80">创建</a>  
  <a href="javascript:void(0)" class="easyui-linkbutton" id="inspection_report_dialog_update" data-options="iconCls:'icon-edit',width:80">修改</a>      
  <a href="javascript:void(0)" class="easyui-linkbutton" id="inspection_report_dialog_delete" data-options="iconCls:'icon-remove',width:80">删除</a>  
  <a href="javascript:void(0)" class="easyui-linkbutton" id="inspection_report_dialog_export" data-options="iconCls:'icon-export',width:80">导出</a>  
  <a href="javascript:void(0)" class="easyui-linkbutton" id="inspection_report_dialog_cancel" data-options="iconCls:'icon-cancel',width:80">取消</a> 
  <a download="" href="" target="blank" id="downxls"></a>   
</div>           
<!--巡检报告管理窗口-->

<!--创建巡检报告对话窗口-->
<div id="inspection_report_insert_dialog" class="easyui-dialog dialog-default-width" data-options="modal:true,buttons:'#inspection_report_insert_dialog_buttons',closed:true,height:268,closable:true"> <!--modal是遮罩层--> 
 <div style="padding:30px 5px 5px 10px">      
   <form id="inspection_report_insert_dialog_form" method="post"> 
     <table cellpadding="3" width="99%">
       <tr>
         <td align="center" width="120">填写巡检报告名称</td>
         <td colspan="3"><input class="easyui-textbox textbox-default-width-long" name="report_name" data-options="required:true"  ></input></td> 
       </tr>  
       <tr>
         <td align="center" width="120">选择统计的数据库</td>
         <td colspan="3"><select class="easyui-combobox textbox-default-width-long" name="database" id="inspection_report_insert_database" data-options="editable:false,panelHeight:'auto',valueField: 'datname',textField: 'dattext'"></select></td> 
       </tr>
       <tr>
         <td align="center" width="120">表行数统计进程数</td>
         <td colspan="3"><input class="easyui-textbox textbox-default-width-long" name="count_recordnum_processes" data-options="required:true,value:'0'"  ></input></td> 
       </tr> 
       <tr>
         <td align="center" width="120">是否统计系统对象</td>
         <td colspan="3"><select class="easyui-combobox textbox-default-width-long" name="count_system_obj" id="count_system_obj" data-options="editable:false,panelHeight:'auto',valueField: 'value',textField: 'label',data: [{label: '不统计',value: '不统计',selected:true},{label: '统计',value: '统计'}]"></select></td> 
       </tr>   
     </table>         
   </form>
 </div>
</div>
<div id="inspection_report_insert_dialog_buttons">
  <a href="javascript:void(0)" class="easyui-linkbutton c2" id="inspection_report_insert_dialog_save" data-options="iconCls:'icon-save',width:100">确认创建</a>
  <a href="javascript:void(0)" class="easyui-linkbutton" id="inspection_report_insert_dialog_cancel" data-options="iconCls:'icon-cancel',width:80">取消</a>
</div>                    
<!--创建巡检报告对话窗口-->

<!--进程管理窗口-->
<div id="processadmin_dialog" class="easyui-dialog" data-options="modal:true,buttons:'#processadmin_dialog_button',closed:true,width:1250,height:550,resizable:true,closable:true,maximizable:true,iconCls:'icon-process'"> <!--modal是遮罩层--> 
</div> 
<div id="processadmin_dialog_button">
  <a href="javascript:void(0)" class="easyui-linkbutton" id="processadmin_dialog_cancelquery" data-options="iconCls:'icon-cancelquery',width:100">取消查询</a>  
  <a href="javascript:void(0)" class="easyui-linkbutton c5" id="processadmin_dialog_killprocess" data-options="iconCls:'icon-killprocess',width:100">杀死进程</a>      
  <a href="javascript:void(0)" class="easyui-linkbutton" id="processadmin_dialog_cancel" data-options="iconCls:'icon-cancel',width:80">取消</a>
</div>           
<!--进程管理窗口-->

<!--表锁管理窗口-->
<div id="lockadmin_dialog" class="easyui-dialog" data-options="modal:true,buttons:'#lockadmin_dialog_button',closed:true,width:1250,height:550,resizable:true,closable:true,maximizable:true,iconCls:'icon-unlock'"> <!--modal是遮罩层--> 
</div> 
<div id="lockadmin_dialog_button">
  <a href="javascript:void(0)" class="easyui-linkbutton" id="lockadmin_dialog_cancelquery" data-options="iconCls:'icon-cancelquery',width:100,disabled:true">取消查询</a>  
  <a href="javascript:void(0)" class="easyui-linkbutton c5" id="lockadmin_dialog_killprocess" data-options="iconCls:'icon-killprocess',width:100,disabled:true">杀死进程</a>      
  <a href="javascript:void(0)" class="easyui-linkbutton" id="lockadmin_dialog_commit" data-options="iconCls:'icon-commit',width:100,disabled:true">提交事务</a>  
  <a href="javascript:void(0)" class="easyui-linkbutton" id="lockadmin_dialog_rollback" data-options="iconCls:'icon-rollback',width:100,disabled:true">回滚事务</a>      
  <a href="javascript:void(0)" class="easyui-linkbutton" id="lockadmin_dialog_cancel" data-options="iconCls:'icon-cancel',width:80">取消</a>
</div>           
<!--表锁管理窗口-->

<!--查询统计窗口-->
<div id="querycount_dialog" class="easyui-dialog" data-options="modal:true,buttons:'#querycount_dialog_button',closed:true,width:1250,height:550,resizable:true,closable:true,maximizable:true,iconCls:'icon-process'"> <!--modal是遮罩层--> 
</div> 
<div id="querycount_dialog_button">
  <a href="javascript:void(0)" class="easyui-linkbutton c5" id="querycount_dialog_countreset" data-options="iconCls:'icon-count',width:100">重新统计</a>
  <!--<a href="javascript:void(0)" class="easyui-linkbutton" id="querycount_dialog_export" data-options="iconCls:'icon-export',width:80">导出</a>-->  
  <a href="javascript:void(0)" class="easyui-linkbutton" id="querycount_dialog_cancel" data-options="iconCls:'icon-cancel',width:80">取消</a>
</div>           
<!--查询统计窗口-->

<!--操作员密码修改窗口-->
<div id="password_update_dialog" class="easyui-dialog" data-options="modal:true,closed:true,width:500,height:350,resizable:false,closable:true,iconCls:'icon-password'"> <!--modal是遮罩层--> 
 <div style="padding:30px 5px 5px 10px">      
 <form id="password_update_dialog_form" method="post">
    <div style="margin-bottom:20px;text-align:center;">
      <input class="easyui-passwordbox" name="old_password" id="old_password" prompt="旧密码" iconWidth="30" data-options="required:false" style="width:50%;height:42px;padding:10px"/>
    </div>
    <div style="margin-bottom:20px;text-align:center;">
      <input class="easyui-passwordbox" name="new_password" id="new_password" prompt="新密码" iconWidth="30" data-options="required:false" style="width:50%;height:42px;padding:10px"/>
    </div>
    <div style="margin-bottom:20px;text-align:center;">
      <input class="easyui-passwordbox" name="new_password_confirm" id="new_password_confirm" prompt="新密码确认" iconWidth="30" data-options="required:false,validType:['password_equal[\'#new_password\']']" style="width:50%;height:42px;padding:10px"/>
    </div>
    <div style="text-align:center;padding:5px 0">
      <a href="javascript:void(0)" class="easyui-linkbutton c5" id="password_update"  data-options="plain:true" style="width:50%;height:35px">确认修改</a>
    </div>
  </form>  
 </div>
</div>            
<!--操作员密码修改窗口-->

<!--登录窗口-->
<div id="login_dialog" class="easyui-dialog" data-options="modal:true,closed:true,width:500,height:350,resizable:false,closable:false,iconCls:'icon-lock'"> <!--modal是遮罩层--> 
 <div style="padding:50px 5px 5px 10px">      
 <form id="login_dialog_form" method="post">
    <div style="margin-bottom:20px;text-align:center;">
      <input class="easyui-textbox" prompt="登录账号" name="username" id="username" data-options="iconCls:'icon-man',iconWidth:30" style="width:50%;height:42px;padding:10px;">
    </div>
    <div style="margin-bottom:20px;text-align:center;">
      <input class="easyui-passwordbox" name="password" id="password" prompt="登录密码" iconWidth="30" data-options="required:false" style="width:50%;height:42px;padding:10px"/>
    </div>    
    <div style="text-align:center;padding:5px 0">
      <a href="javascript:void(0)" class="easyui-linkbutton c5" id="login_dialog_login"  data-options="plain:true" style="width:50%;height:35px">登录</a>
    </div>
  </form>  
 </div>
</div>            
<!--登录窗口-->

 
<script type="text/javascript">



var url="";

$(document).ready(function()
{     
    //数据表属性初始化       
    $('#dg').datagrid({
        'title':'Postgresql集群管理器',   
        'rownumbers':true,
        'singleSelect':true,
        'checkOnSelect':false,
        'selectOnCheck':false,
        'method':'post',
        'sortName':'createtime',
        'sortOrder':'desc',  
        'fitColumns':false,
        'multiSort':false,
        'pagination':true,
        'remoteSort':true,
        'height':$(window).height()-35,
        'width':'100%',
        'idField':'id',
        'pageSize':100,
        'pageList':[10,20,30,40,50,100,500,1000],
        'url':'/getnoderows/',
        'toolbar': '#tb',
        'onDblClickRow':function(rowIndex, rowData){       
            $('#cy_update_click').click();
        }
    });  
    
    //操作员登录
    $('#login_dialog_login').bind('click', function(){
        $('#username').textbox({"required":true});  
        $('#password').passwordbox({"value":$('#password').passwordbox("getValue"),"required":true});
        $('#login_dialog_form').form('submit', {
            "url":'./login/', 
            onSubmit: function(){
                var validate = $(this).form('validate'); 
                if ( validate ){
                    $.messager.progress();    
                    return true;
                }
                return false;
            },
            success: function(result){
                $.messager.progress('close');    
                var result = eval('('+result+')');  
                if (result.return_code=="FAIL")                               
                    {
                        $.messager.alert('错误提示',result.return_msg, 'error');      
                    }   
                else
                    {
                        $('#dg').datagrid('reload');
                        $('#username').textbox({"value":"","required":false});  
                        $('#password').passwordbox({"value":"","required":false});
                        $('#login_dialog').dialog('close');
                    }       
           }
        });        
    });   
    
    //增加节点资料
    $('#cy_insert_click').bind('click', function(){  
		$('#update_dialog').dialog({'iconCls':'icon-add'});    
        $('#update_dialog').dialog('open').dialog('center').dialog('setTitle','增加一个节点资料');  
        $('#update_dialog_form').form('clear'); 
        $('#update_dialog_form').form('load',{'ssh_port':'22','ssh_user':'postgres','pg_bin':'/usr/local/pgsql/bin/','pg_data':'/home/postgres/data/','pg_port':'5432','pg_database':'template1','pg_user':'postgres','ssh_authmethod':'key','bind_vip_authmethod':'key'});   
        url="./insertnode/";
    }); 
    
    //修改节点资料
    $('#cy_update_click').bind('click', function(){  
        var row = $('#dg').datagrid('getSelected');    
        if (!row)
            {
                var rows = $('#dg').datagrid('getChecked');  
                if (rows.length!=1)
                     {
                          $.messager.alert('系统提示',"请选择要修改的节点", 'warning');    
                          return;
                     }
                $('#dg').datagrid('selectRow',$('#dg').datagrid('getRowIndex',rows[0]));
                var row = $('#dg').datagrid('getSelected');      
            } 
		$('#update_dialog').dialog({'iconCls':'icon-edit'});     
        $('#update_dialog').dialog('open').dialog('center').dialog('setTitle','修改节点资料');
        $('#update_dialog_form').form('load',row);  
        url="./updatenode/";
    });       
    
    //修改节点资料－－保存按钮
    $('#update_dialog_save').bind('click', function(){
        $('#update_dialog_form').form('submit', {
            "url":url, 
            onSubmit: function(){  
                var isValid = $(this).form('validate');
                if (isValid){
                     $.messager.progress();     
                     return true;                     
                }
                return false;
            },
            success: function(result){
                $.messager.progress('close');       
                var result = eval('('+result+')');  
                if (result.return_code=="FAIL")                               
                    {                           
                        if ( result.show_login_dialog == 1)
                            {   
                                $('#login_dialog').dialog('open').dialog('center').dialog('setTitle','系统无法训别你的身份--操作员重新登录'); 
                            }
                        else
                            {
                                $.messager.alert('错误提示',result.return_msg, 'error');   
                            }
                    }   
                else
                    {
                        $.messager.alert('系统提示',result.return_msg, 'info');      
                        $('#dg').datagrid('reload');
                        $('#update_dialog').dialog('close');
                    } 
           }
        });         
    });
	 
	//SSH认证方式选择时设置是否需要录入密码
	$('#update_ssh_authmethod').combobox({onSelect: function(rec){ssh_authmethod_onselect(rec)}});
	function ssh_authmethod_onselect(rec){
		var val = $('#update_ssh_password').passwordbox('getValue');
		if (rec.value == "password") {
			$('#update_ssh_password').passwordbox({value:val,'required':true});
		}else{
			$('#update_ssh_password').passwordbox({value:val,'required':false});
		}
	}
	
	//绑定网卡登录认证方式选择时设置是否需要录入密码
	$('#update_bind_vip_authmethod').combobox({onSelect: function(rec){bind_vip_authmethod_onselect(rec)}});
	function bind_vip_authmethod_onselect(rec){
		var val = $('#update_bind_vip_password').passwordbox('getValue');
		if (rec.value == "password") {
			$('#update_bind_vip_password').passwordbox({value:val,'required':true});
		}else{
			$('#update_bind_vip_password').passwordbox({value:val,'required':false});
		}
	}
    
    //修改节点资料－－取消按钮
    $('#update_dialog_cancel').bind('click', function(){
        $('#update_dialog').dialog('close');
    });  
    
    //删除节点资料
    $('#cy_delete_click').bind('click', function(){    
        var row = $('#dg').datagrid('getSelected');    
        if (!row)
            {
                 var rows = $('#dg').datagrid('getChecked'); 
                 if (rows.length!=1)
                     {
                          $.messager.alert('系统提示',"请选择要删除的节点", 'warning'); 
                          return;
                     }
                 $('#dg').datagrid('selectRow',$('#dg').datagrid('getRowIndex',rows[0]));
                 var row = $('#dg').datagrid('getSelected');      
            }  
        $.messager.confirm('删除节点记录确认', '你确认要删除这个节点<font color=red>[ ' + row.node_name + ' ]</font>记录（非物理删除节点文件）?', function(r){
            if (r)
                {    
                     $.messager.progress();   
                     $.ajax({
                         type:"POST",
                         url:"/deletenode/",
                         data:{id:row.id},
                         success:function(result){
                             $.messager.progress('close');   
                             if (result.return_code=="FAIL")                               
                                 {                       
                                     if ( result.show_login_dialog == 1)
                                         {   
                                             $('#login_dialog').dialog('open').dialog('center').dialog('setTitle','系统无法训别你的身份--操作员重新登录'); 
                                         }
                                     else
                                         {
                                             $.messager.alert('错误提示',result.return_msg, 'error');   
                                         }
                                 }
                             else
                                 {
                                     $.messager.alert('系统提示',result.return_msg, 'info');   
                                     var row = $('#dg').datagrid('getSelected');  
                                     var index = $('#dg').datagrid('getRowIndex',row);      
                                     $('#dg').datagrid('deleteRow',index);
                                 }  
                         },
                         dataType:"json"
                     });      
                }
        });
    }); 
    
    //参数配置管理
    $('#cy_parameter_click').bind('click',function(){
        var row = $('#dg').datagrid('getSelected');
        if (!row)
            {    
                var rows = $('#dg').datagrid('getChecked'); 
                if (rows.length!=1)
                    {
                         $.messager.alert('系统提示',"请选择要操作的节点", 'warning'); 
                         return;
                    } 
                $('#dg').datagrid('selectRow',$('#dg').datagrid('getRowIndex',rows[0]));
                var row = $('#dg').datagrid('getSelected');    
            }                                                  
        $('#parameter_dialog').dialog('open').dialog('center').dialog('setTitle','参数配置');
        $('#parameter_dialog_form').form('clear');  
		data = [{label: 'postgresql.conf',value: 'postgresql.conf'},{label: 'pg_hba.conf',value: 'pg_hba.conf'}]
		if (row.service_type == "备节点" || row.service_status == "服务停止")
			{
				data.push({ "label": "recovery.conf", "value": "recovery.conf" });  
			}
		row.remark = ""
		$('#parameter_files').combobox("loadData", data); 
        $('#parameter_dialog_form').form('load',row);   
        $('#parameter_files').combobox('select','postgresql.conf');
    });
	
    //绑定“配置文件”选择事件
    $('#parameter_files').combobox({'onSelect':function(record){parameter_file_load(record);}});
	
    //参数配置管理-保存
    $('#parameter_dialog_save').bind('click', function(){
        parameter_save('save');
    }); 
    
    //参数配置管理-保存reload
    $('#parameter_dialog_reload').bind('click', function(){
        parameter_save('reload');
    }); 
    
    //参数配置管理-保存restart
    $('#parameter_dialog_restart').bind('click', function(){
        parameter_save('restart');
    }); 
	
	//参数配置管理-保存saveas_template
    $('#parameter_dialog_saveas_template').bind('click', function(){
        parameter_save('saveas_template');
    }); 
    
    //提交配置的参数
    function parameter_save(act){
		if ( $('#parameter_remark').textbox('getValue') == ""){
			$.messager.alert('错误提示',"备注不能为空", 'error'); 
			return;
		}
        $.messager.progress();   
        $.ajax({        
                type:"POST",
                url:"/parameter_save/",
                data:{'id':$('#parameter_id').textbox('getValue'),'parameter_file_name':$('#parameter_files').combobox('getValue'),'act':act,'parameter_file_contents':$('#parameter_file_contents').textbox('getValue'),'remark':$('#parameter_remark').textbox('getValue')},
                success:function(result){
                    $.messager.progress('close');   
                    if (result.return_code=="FAIL")                               
                        {                       
                            if ( result.show_login_dialog == 1)
                                {   
									$('#parameter_dialog').dialog('close');
                                    $('#login_dialog').dialog('open').dialog('center').dialog('setTitle','系统无法训别你的身份--操作员重新登录'); 
                                }
                            else
                                {
                                    $.messager.alert('错误提示',"执行失败,详情见 [ 执行结果 ] 输出框", 'error');   
									$('#parameter_exec_result').textbox('setValue',result.return_msg);   
									if (result.service_status) 
										{
											$('#parameter_service_status').textbox('setValue',result.service_status);    
					                        $('#parameter_service_type').textbox('setValue',result.service_type);    
					                        $('#parameter_pg_version').textbox('setValue',result.pg_version);    
					                        var index = $('#dg').datagrid('getRowIndex', $("#dg").datagrid('getSelected'))
					                        $('#dg').datagrid('updateRow',{'index':index , 'row' : {'service_status':result.service_status , 'service_type':result.service_type , 'pg_version':result.pg_version}});                   
										} 
									//重新加载备份和模板文件列表 
									parameter_files_refresh();
                                }
                        }
                    else
                        {      
						    if (act == "save" || act == "saveas_template")
							    {
									alertmsg = "执行成功";
								}
							else
								{
									alertmsg = "执行成功,详情见 [ 执行结果 ] 输出框";
									$('#parameter_exec_result').textbox('setValue',result.return_msg);   
								}	
                            $.messager.alert('系统提示',alertmsg, 'info');  
							if (result.service_status) 
								{
									$('#parameter_service_status').textbox('setValue',result.service_status);    
			                        $('#parameter_service_type').textbox('setValue',result.service_type);    
			                        $('#parameter_pg_version').textbox('setValue',result.pg_version);    
			                        var index = $('#dg').datagrid('getRowIndex', $("#dg").datagrid('getSelected'))
			                        $('#dg').datagrid('updateRow',{'index':index , 'row' : {'service_status':result.service_status , 'service_type':result.service_type , 'pg_version':result.pg_version}});                   
								}
							//重新加载备份和模板文件列表 
							parameter_files_refresh();
                        }
                },
                dataType:"json"
            });      
    }
    
    //参数配置管理-获取配置文件内容
    function parameter_file_load(record) {
        if ($('#parameter_id').textbox('getValue') == "") return ;
        $.messager.progress();   
        $('#parameter_file_contents').textbox('setValue',"数据加载中...");
        $.ajax({        
                type:"POST",
                url:"/parameter_get_file_contents/",
                data:{'id':$('#parameter_id').textbox('getValue'),'parameter_file_name':record.value},
                success:function(result){
                    $.messager.progress('close');   
                    if (result.return_code=="FAIL")                               
                        {                       
                            if ( result.show_login_dialog == 1)
                                {   
									$('#parameter_dialog').dialog('close');
                                    $('#login_dialog').dialog('open').dialog('center').dialog('setTitle','系统无法训别你的身份--操作员重新登录'); 
                                }
                            else
                                {
                                    $.messager.alert('错误提示',result.return_msg, 'error');   
									//重新加载备份和模板文件列表 
									parameter_files_refresh();	  
									
                                }
                        }
                    else
                        {      
							s = result.parameter_file_conetens;
							s = s.substring(0,s.length-1);
                            $('#parameter_file_contents').textbox('setValue',s);  
							//重新加载备份和模板文件列表 
							parameter_files_refresh();
                        }
                },
                dataType:"json"
            });      
    }
	
	//刷新历史备份和模板文件列表
	function parameter_files_refresh(){
		$('#parameter_files_bak').combogrid({url: '/parameter_bak_template_list/?id=' + $('#parameter_id').textbox('getValue') + "&filename=" + $('#parameter_files').combobox('getValue') + "&category=bak"});    
		$('#parameter_files_template').combogrid({url: '/parameter_bak_template_list/?id=' + $('#parameter_id').textbox('getValue') + "&filename=" + $('#parameter_files').combobox('getValue') + "&category=template"});    
	}
	//历史备份选择框列表属性设置       
    $('#parameter_files_bak').combogrid({
		editable:false,
        panelWidth: 705,
		panelHeight: 300,
		idField: 'id',
		textField: 'remark',
		method: 'get',
		columns: [[
			{field:'id',title:'Id号',width:55,align:'center'},
			{field:'createtime',title:'备份时间',width:150,align:'left'},
			{field:'username',title:'操作员',width:150,align:'left'},
			{field:'remark',title:'备注',width:150,align:'left'},
			{field:'version',title:'PG版本号',width:200,align:'left'},
			{field:'import',title:'导入',width:50,align:'center',formatter:function(value,rec,index){return "<a href=\"#\" onclick=\"parameter_files_bak_template_load('bak',"+rec.id+","+index+")\">导入</a> ";}},
			{field:'delete',title:'删除',width:50,align:'center',formatter:function(value,rec,index){return "<a href=\"#\" onclick=\"parameter_files_bak_template_delete('bak',"+rec.id+","+index+")\">删除</a> ";}}
		]],
		fitColumns: true
    });  
	
	//模板文件选择框列表属性设置       
    $('#parameter_files_template').combogrid({
		editable:false,
        panelWidth: 705,
		panelHeight: 300,
		idField: 'id',
		textField: 'remark',
		method: 'get',
		columns: [[
			{field:'id',title:'Id号',width:55,align:'center'},
			{field:'createtime',title:'创建时间',width:150,align:'left'},
			{field:'username',title:'操作员',width:150,align:'left'},
			{field:'remark',title:'备注',width:150,align:'left'},
			{field:'version',title:'PG版本号',width:150,align:'left'},
			{field:'import',title:'导入',width:50,align:'center',formatter:function(value,rec,index){return "<a href=\"#\" onclick=\"parameter_files_bak_template_load('template',"+rec.id+","+index+")\">导入</a> ";}},
			{field:'delete',title:'删除',width:50,align:'center',formatter:function(value,rec,index){return "<a href=\"#\" onclick=\"parameter_files_bak_template_delete('template',"+rec.id+","+index+")\">删除</a> ";}}
		]],
		fitColumns: true
    });  
    
    //参数配置－－取消按钮
    $('#parameter_dialog_cancel').bind('click', function(){
        $('#parameter_dialog').dialog('close');
    });  
    
    //节点服务管理
    $('#cy_serviceadmin_click').bind('click', function(){  
        var row = $('#dg').datagrid('getSelected');
        if (!row)
            {    
                var rows = $('#dg').datagrid('getChecked'); 
                if (rows.length!=1)
                    {
                         $.messager.alert('系统提示',"请选择要操作的节点", 'warning'); 
                         return;
                    } 
                $('#dg').datagrid('selectRow',$('#dg').datagrid('getRowIndex',rows[0]));
                var row = $('#dg').datagrid('getSelected');    
            }                                                  
        $('#serviceadmin_dialog').dialog('open').dialog('center').dialog('setTitle','服务管理');
        $('#serviceadmin_dialog_form').form('clear');  
        row.mode = "fast" ;
        $('#serviceadmin_dialog_form').form('load',row);   
    }); 
    
    //start服务
    $('#serviceadmin_dialog_start').bind('click', function(){   
        serviceadmin("/servicestart/" , "start");         
    }); 
    
    //stop服务
    $('#serviceadmin_dialog_stop').bind('click', function(){   
        serviceadmin("/servicestop/" , "stop");       
    }); 
    
    //restart服务
    $('#serviceadmin_dialog_restart').bind('click', function(){ 
        serviceadmin("/servicerestart/" , "restart");      
    }); 
    
    //reload服务
    $('#serviceadmin_dialog_reload').bind('click', function(){ 
        serviceadmin("/servicereload/" , "reload");      
    }); 
    
    //显示服务status
    $('#serviceadmin_dialog_status').bind('click', function(){ 
        serviceadmin("/servicestatus/" , "status");      
    }); 
    
    //执行管理管理操作
    function serviceadmin(url,act){
        $('#serviceadmin_dialog_form').form('submit', {
            "url":url, 
            onSubmit: function(){ 
                var isValid = $(this).form('validate');
                if (isValid){
                    var run_command = "";
                    run_command = run_command + $('#pg_bin').textbox('getValue') + "pg_ctl ";
                    run_command = run_command + act + " -D ";
                    run_command = run_command + $('#pg_data').textbox('getValue');
                    if (act == "stop" || act == "restart")
                        {
                            run_command = run_command + " -m " + $('#mode').textbox('getValue');      
                        } 
                    $('#run_command').textbox('setValue',run_command); 
                    $.messager.progress();   
                    return true;
                }
                return false;
            },
            success: function(result){
                $.messager.progress('close');  
                var result = eval('('+result+')');  
                if (result.return_code=="FAIL")                               
                    {                           
                        if ( result.show_login_dialog == 1)
                            {   
                                $('#login_dialog').dialog('open').dialog('center').dialog('setTitle','系统无法训别你的身份--操作员重新登录'); 
                            }
                        else
                            {
                                $.messager.alert('错误提示',"执行失败,详情见 [ 执行结果 ] 输出框", 'error');  
                                $('#exec_result').textbox('setValue',result.return_msg);  
                                $('#service_status').textbox('setValue',result.service_status);    
                                $('#service_type').textbox('setValue',result.service_type);    
                                $('#pg_version').textbox('setValue',result.pg_version);    
                                var index = $('#dg').datagrid('getRowIndex', $("#dg").datagrid('getSelected'))
                                $('#dg').datagrid('updateRow',{'index':index , 'row' : {'service_status':result.service_status , 'service_type':result.service_type , 'pg_version':result.pg_version}});                   
                            }
                    }   
                else
                    {                             
                        $.messager.alert('系统提示',act+"服务完成,详情见 [ 执行结果 ] 输出框", 'info');     
                        $('#exec_result').textbox('setValue',result.return_msg);    
                        $('#service_status').textbox('setValue',result.service_status);    
                        $('#service_type').textbox('setValue',result.service_type);    
                        $('#pg_version').textbox('setValue',result.pg_version);    
                        var index = $('#dg').datagrid('getRowIndex', $("#dg").datagrid('getSelected'))
                        $('#dg').datagrid('updateRow',{'index':index , 'row' : {'service_status':result.service_status , 'service_type':result.service_type , 'pg_version':result.pg_version}});                   
                    }       
           }
        });       
    }
    
    //服务管理－－取消按钮
    $('#serviceadmin_dialog_cancel').bind('click', function(){
        $('#serviceadmin_dialog').dialog('close');
    });  
    
    //vip管理
    $('#cy_vipadmin_click').bind('click', function(){  
        var row = $('#dg').datagrid('getSelected');
        if (!row)
            {
                var rows = $('#dg').datagrid('getChecked');  
                if (rows.length!=1)
                     {
                          $.messager.alert('系统提示',"请选择要执行VIP管理的节点", 'warning');    
                          return;
                     }
                $('#dg').datagrid('selectRow',$('#dg').datagrid('getRowIndex',rows[0]));
                var row = $('#dg').datagrid('getSelected');      
            }  
        $('#vipadmin_dialog').dialog('open').dialog('center').dialog('setTitle','VIP绑定管理');
        $('#vipadmin_dialog_form').form('clear');  
        if (row.service_type =="主节点" )
            {
                row.vip = row.master_vip;
                row.vip_networkcard =row.master_vip_networkcard;
            }
        if (row.service_type =="备节点" )
            {
                row.vip = row.slave_vip;
                row.vip_networkcard =row.slave_vip_networkcard;
            }
        $('#vipadmin_dialog_form').form('load',row);   
        $('#vipadmin_dialog_ip_refresh').click();
    }); 
	
	//绑定网卡登录认证方式选择时设置是否需要录入密码
	$('#vipadmin_bind_vip_authmethod').combobox({onSelect: function(rec){vipadmin_bind_vip_authmethod_onselect(rec)}});
	function vipadmin_bind_vip_authmethod_onselect(rec){
		var val = $('#vipadmin_bind_vip_password').passwordbox('getValue');
		if (rec.value == "password") {
			$('#vipadmin_bind_vip_password').passwordbox({value:val,'required':true});
		}else{
			$('#vipadmin_bind_vip_password').passwordbox({value:val,'required':false});
		}
	}
    
    //vip管理－－绑定按钮
    $('#vipadmin_dialog_bind').bind('click', function(){
        vipadmin("bind")
    });
    
    //vip管理－－解绑按钮
    $('#vipadmin_dialog_unbind').bind('click', function(){
        vipadmin("unbind")
    });
    
    //vip管理--执行操作
    function vipadmin(act) {
        $('#vipadmin_dialog_form').form('submit', {
            "url":"/vipadmin/", 
            onSubmit: function(param){  
                param.act = act;
                var isValid = $(this).form('validate');
                if (isValid){
                     $.messager.progress();     
                     return true;                     
                }
                return false;
            },
            success: function(result){
                $.messager.progress('close');       
                var result = eval('('+result+')');  
                if (result.return_code=="FAIL")                               
                    {                           
                        if ( result.show_login_dialog == 1)
                            {   
                                $('#login_dialog').dialog('open').dialog('center').dialog('setTitle','系统无法训别你的身份--操作员重新登录'); 
                            }
                        else
                            {
                                $.messager.alert('错误提示',result.return_msg, 'error');   
                            }
                    }   
                else
                    {
                        $.messager.alert('系统提示',result.return_msg, 'info');      
                        $('#vipadmin_dialog_ip_refresh').click();  
                    } 
           }
        });         
    } 
    
    //vip管理--刷新ip绑定详情
    $('#vipadmin_dialog_ip_refresh').bind('click',function(){
        //$.messager.progress();   
        $('#vipadmin_dialog_ip_refresh').linkbutton("disable");
        $('#vipadmin_ip_status').textbox('setValue',"数据加载中...");
        $.ajax({        
                type:"POST",
                url:"/get_ip_bind_status/",
                data:{'id':$('#vipadmin_id').textbox('getValue')},
                success:function(result){
                    //$.messager.progress('close');   
                    $('#vipadmin_dialog_ip_refresh').linkbutton("enable");        
                    if (result.return_code=="FAIL")                               
                        {                       
                            if ( result.show_login_dialog == 1)
                                {   
                                    $('#login_dialog').dialog('open').dialog('center').dialog('setTitle','系统无法训别你的身份--操作员重新登录'); 
                                    //$('#promote_dialog').dialog('close');
                                }
                            else
                                {
                                    $.messager.alert('错误提示',result.return_msg, 'error');   
                                }
                        }
                    else
                        {
                            $('#vipadmin_ip_status').textbox('setValue',result.ip_bind_status);
                        }  
                },
                dataType:"json"
            });      
    });
    
    //vip管理－－取消按钮
    $('#vipadmin_dialog_cancel').bind('click', function(){
        $('#vipadmin_dialog').dialog('close');
    });  
	
    //备机唤醒管理
    $('#cy_slave_wakeup_click').bind('click', function(){  
        var row = $('#dg').datagrid('getSelected');
        if (!row)
            {
                var rows = $('#dg').datagrid('getChecked');  
                if (rows.length!=1)
                     {
                          $.messager.alert('系统提示',"请选择要执行唤醒的备节点", 'warning');    
                          return;
                     }
                $('#dg').datagrid('selectRow',$('#dg').datagrid('getRowIndex',rows[0]));
                var row = $('#dg').datagrid('getSelected');      
            }         
        if (row.service_type!="备节点")
            {
                $.messager.alert('系统提示',"您选择要唤醒的节点不是备节点", 'warning');    
                return; 
            } 
        
        $('#slave_wakeup_dialog').dialog('open').dialog('center').dialog('setTitle','备机唤醒管理');
        $('#slave_wakeup_dialog_form').form('clear');  
        row.vip = row.master_vip;
        row.vip_networkcard =row.master_vip_networkcard;
        $('#slave_wakeup_dialog_form').form('load',row); 
        $('#vacuum_check').switchbutton({'checked':true});  
        $('#slave_wakeup_dialog_ip_refresh').click();
		$('#slave_wakeup_dialog_run').linkbutton("enabled");  
    }); 
	
	//绑定网卡登录认证方式选择时设置是否需要录入密码
	$('#slave_wakeup_bind_vip_authmethod').combobox({onSelect: function(rec){slave_wakeup_bind_vip_authmethod_onselect(rec)}});
	function slave_wakeup_bind_vip_authmethod_onselect(rec){
		var val = $('#slave_wakeup_bind_vip_password').passwordbox('getValue');
		if (rec.value == "password") {
			$('#slave_wakeup_bind_vip_password').passwordbox({value:val,'required':true});
		}else{
			$('#slave_wakeup_bind_vip_password').passwordbox({value:val,'required':false});
		}
	}
    
    //唤醒管理--执行操作
    $('#slave_wakeup_dialog_run').bind('click', function() {
		$.messager.confirm('备机唤醒确认','你确认要执行备机唤醒操作吗', function(r){
			if (r){
				$('#slave_wakeup_dialog_form').form('submit', {
		            "url":"/slave_wakeup/", 
		            onSubmit: function(param){  
		                var isValid = $(this).form('validate');
		                if (isValid){
		                     $.messager.progress();     
		                     return true;                     
		                }
		                return false;
		            },
		            success: function(result){
		                $.messager.progress('close');       
		                var result = eval('('+result+')');  
		                if (result.return_code=="FAIL")                               
		                    {                           
		                        if ( result.show_login_dialog == 1)
		                            {   
		                                $('#login_dialog').dialog('open').dialog('center').dialog('setTitle','系统无法训别你的身份--操作员重新登录'); 
		                            }
		                        else
		                            {
		                                $.messager.alert('错误提示',result.return_msg, 'error');   
		                            }
		                    }   
		                else
		                    {
								$('#slave_wakeup_dialog_run').linkbutton("disable");     
		                        $.messager.alert('系统提示',result.return_msg, 'info');      
								$('#wakeup_service_type').textbox('setValue',"主节点");    
		                        var index = $('#dg').datagrid('getRowIndex', $("#dg").datagrid('getSelected'))
		                        $('#dg').datagrid('updateRow',{'index':index , 'row' : {'service_type':'主节点'}});                   
		                        if ($('#salve_makeup_vip').textbox('getValue')!="")
		                            {
		                                 $('#slave_makeup_dialog_ip_refresh').click();  
		                            } 
		                    } 
		           }
		        }); 
			}
		});     
    }); 
    
    //唤醒管理--刷新ip绑定详情
    $('#slave_wakeup_dialog_ip_refresh').bind('click',function(){
        //$.messager.progress();   
        $('#slave_wakeup_dialog_ip_refresh').linkbutton("disable");
        $('#slave_wakeup_ip_status').textbox('setValue',"数据加载中...");
        $.ajax({        
                type:"POST",
                url:"/get_ip_bind_status/",
                data:{'id':$('#slave_wakeup_id').textbox('getValue')},
                success:function(result){
                    //$.messager.progress('close');   
                    $('#slave_wakeup_dialog_ip_refresh').linkbutton("enable");        
                    if (result.return_code=="FAIL")                               
                        {                       
                            if ( result.show_login_dialog == 1)
                                {   
                                    $('#login_dialog').dialog('open').dialog('center').dialog('setTitle','系统无法训别你的身份--操作员重新登录'); 
                                    //$('#promote_dialog').dialog('close');
                                }
                            else
                                {
                                    $.messager.alert('错误提示',result.return_msg, 'error');   
                                }
                        }
                    else
                        {
                            $('#slave_wakeup_ip_status').textbox('setValue',result.ip_bind_status);
                        }  
                },
                dataType:"json"
            });      
    });
    
    //唤醒管理－－取消按钮
    $('#slave_wakeup_dialog_cancel').bind('click', function(){
        $('#slave_wakeup_dialog').dialog('close');
    });  
    
    //节点主备切换管理
    $('#cy_promote_click').bind('click', function(){  
        var rows = $('#dg').datagrid('getChecked'); 
        if (rows.length!=2)
            {
                $.messager.alert('系统提示',"请选择要执行主备切换的两个节点", 'warning');    
                return;   
            }
        if ((rows[0].service_type=="主节点" && rows[1].service_type=="主节点") || (rows[0].service_type=="备节点" && rows[1].service_type=="备节点") || (rows[0].service_type=="普通节点" || rows[1].service_type=="普通节点")) 
            { 
                $.messager.alert('系统提示',"主备切换需要一主一备两个节点", 'warning');    
                return;   
            }
        if (rows[0].service_status!="运行中"  || rows[0].service_status!="运行中") 
            { 
                $.messager.alert('系统提示',"主备切换需要两个节点都处于运行中状态", 'warning');    
                return;   
            }
        for(var i=0; i<rows.length; i++)
            {
                 if ( rows[i].service_type=="主节点" )
                     {
                          var master_row = rows[i];
                     }
                 else
                     {
                          var slave_row = rows[i];
                     }
            }  
        //构造recovery.conf文件内容
        var recovery_conf = "";
        recovery_conf = "archive_cleanup_command = '" + master_row.pg_bin + "pg_archivecleanup " + master_row.pg_data + "pg_xlog %r'\n";
        recovery_conf = recovery_conf + "standby_mode = 'on'\n" ;
        recovery_conf = recovery_conf + "primary_conninfo = 'host=" + slave_row.host + " port=" + slave_row.pg_port + " user=" + slave_row.pg_user + " password=" + slave_row.pg_password + "'\n";
        recovery_conf = recovery_conf + "recovery_target_timeline = 'latest'";
        var formrow = {
            'master_id':master_row.id,
            'master_node_name':master_row.node_name,
            'master_service_type':master_row.service_type,
            'master_service_status':master_row.service_status,
            'master_pg_version':master_row.pg_version,
            'master_host':master_row.host,
            'master_ssh_port':master_row.ssh_port,
			'master_ssh_authmethod':master_row.ssh_authmethod,
            'master_ssh_user':master_row.ssh_user,
            'master_ssh_password':master_row.ssh_password,
            'master_pg_bin':master_row.pg_bin,
            'master_pg_data':master_row.pg_data,
            'master_pg_port':master_row.pg_port,
            'master_pg_database':master_row.pg_database,
            'master_pg_user':master_row.pg_user, 
            'master_pg_password':master_row.pg_password, 
            'master_unbind_vip':master_row.master_vip,
            'master_unbind_vip_networkcard':master_row.master_vip_networkcard,
            'master_bind_vip':master_row.slave_vip,
            'master_bind_vip_networkcard':master_row.slave_vip_networkcard,
			'master_bind_vip_authmethod':master_row.bind_vip_authmethod,
            'master_bind_user':master_row.bind_vip_user,
            'master_bind_password':master_row.bind_vip_password,
            'slave_id':slave_row.id,
            'slave_node_name':slave_row.node_name,
            'slave_service_type':slave_row.service_type,
            'slave_service_status':slave_row.service_status,
            'slave_pg_version':slave_row.pg_version,
            'slave_host':slave_row.host,
            'slave_ssh_port':slave_row.ssh_port,
			'slave_ssh_authmethod':slave_row.ssh_authmethod,
            'slave_ssh_user':slave_row.ssh_user,
            'slave_ssh_password':slave_row.ssh_password,
            'slave_pg_bin':slave_row.pg_bin,
            'slave_pg_data':slave_row.pg_data,
            'slave_pg_port':slave_row.pg_port,
            'slave_pg_database':slave_row.pg_database,
            'slave_pg_user':slave_row.pg_user, 
            'slave_pg_password':slave_row.pg_password, 
            'slave_unbind_vip':slave_row.slave_vip,
            'slave_unbind_vip_networkcard':slave_row.slave_vip_networkcard,
            'slave_bind_vip':slave_row.master_vip,
            'slave_bind_vip_networkcard':slave_row.master_vip_networkcard,
			'slave_bind_vip_authmethod':slave_row.bind_vip_authmethod,
            'slave_bind_user':slave_row.bind_vip_user,
            'slave_bind_password':slave_row.bind_vip_password,
            'recovery_conf':recovery_conf
        };  
        $('#promote_dialog').dialog('open').dialog('center').dialog('setTitle','主备切换管理');
        $('#promote_dialog_form').form('clear');
        $('#promote_dialog_form').form('load',formrow); 
        
        var tt = $('#promote_tabs').tabs('getTab',0);
        $('#promote_tabs').tabs('update', {'tab':tt, options: {'title': '主节点（'+master_row.node_name+'）'}});
        var tt = $('#promote_tabs').tabs('getTab',1);   
        $('#promote_tabs').tabs('update', {'tab':tt, options: {'title': '备节点（'+slave_row.node_name+'）'}});  
        
        $('#promote_tabs').tabs('select',2);     
        $('#master_unbind_vip').textbox({'required':false});
        $('#master_unbind_vip_networkcard').textbox({'required':false}); 
        $('#master_bind_vip').textbox({'required':false}); 
        $('#master_bind_vip_networkcard').textbox({'required':false}); 
        $('#master_bind_user').textbox({'required':false}); 
        $('#master_bind_password').passwordbox({'value':$('#master_bind_password').passwordbox('getValue'),'required':false}); 
        
        $('#slave_unbind_vip').textbox({'required':false});
        $('#slave_unbind_vip_networkcard').textbox({'required':false}); 
        $('#slave_bind_vip').textbox({'required':false}); 
        $('#slave_bind_vip_networkcard').textbox({'required':false}); 
        $('#slave_bind_user').textbox({'required':false}); 
        $('#slave_bind_password').passwordbox({'value':$('#slave_bind_password').passwordbox('getValue'),'required':false}); 
        
        $('#promote_dialog_ip_refresh').click(); 
        
    }); 
    
    //主务切换管理--刷新ip绑定详情
    $('#promote_dialog_ip_refresh').bind('click',function(){
        //$.messager.progress();   
        $('#promote_dialog_ip_refresh').linkbutton("disable");
        $('#master_ip_status').textbox('setValue',"数据加载中...");
        $('#slave_ip_status').textbox('setValue',"数据加载中...");  
        $.ajax({        
                type:"POST",
                url:"/promote_get_ip_bind_status/",
                data:{'master_id':$('#promote_master_id').textbox('getValue'),'slave_id':$('#promote_slave_id').textbox('getValue')},
                success:function(result){
                    //$.messager.progress('close');   
                    $('#promote_dialog_ip_refresh').linkbutton("enable");        
                    if (result.return_code=="FAIL")                               
                        {                       
                            if ( result.show_login_dialog == 1)
                                {   
                                    $('#login_dialog').dialog('open').dialog('center').dialog('setTitle','系统无法训别你的身份--操作员重新登录'); 
                                    //$('#promote_dialog').dialog('close');
                                }
                            else
                                {
                                    $.messager.alert('错误提示',result.return_msg, 'error');   
                                }
                        }
                    else
                        {
                            $('#master_ip_status').textbox('setValue',result.master_ip_status);
                            $('#slave_ip_status').textbox('setValue',result.slave_ip_status);  
                        }  
                },
                dataType:"json"
            }); 
    });
    
    //主备切换管理－－一键切换
    $('#promote_dialog_start').bind('click',function(){
         $.messager.confirm('主备切换确认','你确认要执行主备切换操作吗', function(r){
             if (r)  
                 {
                     //提交表单
                     promote_dialog_form();
                 }
         }); 
    });       
    
    //提交主备切换表单
    function promote_dialog_form(){
        $('#promote_dialog_form').form('submit', {
            "url":'/promote/',
            onSubmit: function(){
                $('#promote_tabs').tabs('select',2);  
                var master_unbind_vip = $('#master_unbind_vip').textbox('getValue');
                if (master_unbind_vip!=""){
					$('#master_unbind_vip_networkcard').textbox({'required':true});
                }else{
                    $('#master_unbind_vip_networkcard').textbox({'required':false});
                }   
                var master_bind_vip = $('#master_bind_vip').textbox('getValue');
                if (master_bind_vip!=""){
                    $('#master_bind_vip_networkcard').textbox({'required':true});
                }else{
                    $('#master_bind_vip_networkcard').textbox({'required':false});
                }   
                if (master_unbind_vip!="" || master_bind_vip!=""){
                    $('#master_bind_user').textbox({'required':true});    
					if ($('#master_bind_vip_authmethod').combobox('getValue')=="password"){
						$('#master_bind_password').passwordbox({'value':$('#master_bind_password').passwordbox('getValue'),'required':true});    
					}else{
						$('#master_bind_password').passwordbox({'value':$('#master_bind_password').passwordbox('getValue'),'required':false});    
					} 
                }else{
                    $('#master_bind_user').textbox({'required':false});    
                    $('#master_bind_password').passwordbox({'value':$('#master_bind_password').passwordbox('getValue'),'required':false});   
                }
                
                var slave_unbind_vip = $('#slave_unbind_vip').textbox('getValue');
                if (slave_unbind_vip!=""){
                    $('#slave_unbind_vip_networkcard').textbox({'required':true});
                }else{
                    $('#slave_unbind_vip_networkcard').textbox({'required':false});
                }   
                var slave_bind_vip = $('#slave_bind_vip').textbox('getValue');
                if (slave_bind_vip!=""){
                    $('#slave_bind_vip_networkcard').textbox({'required':true});
                }else{
                    $('#slave_bind_vip_networkcard').textbox({'required':false});
                }   
                if (slave_unbind_vip!="" || slave_bind_vip!=""){
                    $('#slave_bind_user').textbox({'required':true});    
					if ($('#slave_bind_vip_authmethod').combobox('getValue')=="password"){
						$('#slave_bind_password').passwordbox({'value':$('#slave_bind_password').passwordbox('getValue'),'required':true});    
					}else{
						$('#slave_bind_password').passwordbox({'value':$('#slave_bind_password').passwordbox('getValue'),'required':false});    
					}
                }else{
                    $('#slave_bind_user').textbox({'required':false});    
                    $('#slave_bind_password').passwordbox({'value':$('#slave_bind_password').passwordbox('getValue'),'required':false});    
                }
                
                var isValid = $(this).form('validate');     
                if (isValid){                    
                    $.messager.progress();     
                    return true;
                } 
                return false;
            },
            success: function(result){
                $.messager.progress('close');  
                var result = eval('('+result+')');  
                if (result.return_code=="FAIL")                               
                    {                           
                        if ( result.show_login_dialog == 1)
                            {   
                                $('#login_dialog').dialog('open').dialog('center').dialog('setTitle','系统无法训别你的身份--操作员重新登录'); 
                            }
                        else
                            {
                                $.messager.alert('错误提示',result.return_msg, 'error');  
                                $('#promote_exec_result').textbox('setValue',result.return_msg); 
                            }
                    }   
                else
                    {   
                        $.messager.alert('系统提示',"主备切换成功", 'info'); 
                        $('#dg').datagrid('reload');   
                        $('#promote_dialog').dialog('close');           
                        
                    }       
            }
        });
    }       
    
    //主备切换管理－－取消按钮
    $('#promote_dialog_cancel').bind('click', function(){
        $('#promote_dialog').dialog('close');     
    });   
    
	
	//打开巡检报表管理窗口
	//$('#inspection_report_dialog').dialog('resize',{width:$(window).width()-200,height:$(window).height()-150});
	//$('#inspection_report_dialog').dialog('maximize');
    $('#cy_inspection_report_click').bind('click', function(){    
	    var row = $('#dg').datagrid('getSelected');    
        if (!row)
            {
                var rows = $('#dg').datagrid('getChecked');  
                if (rows.length!=1)
                     {
                          $.messager.alert('系统提示',"请选择要查看的节点", 'warning');    
                          return;
                     }
                $('#dg').datagrid('selectRow',$('#dg').datagrid('getRowIndex',rows[0]));
                var row = $('#dg').datagrid('getSelected');      
            }  
        $('#inspection_report_dialog').dialog('open').dialog('center').dialog('setTitle','巡检报告管理－－'+row.node_name); 
		
		//清空数据
		$('#inspection_report_list').datagrid('unselectAll');  
		$('#inspection_report_list').datagrid('loadData', { total: 0, rows: [] });   
		inspection_report_clear_data();
		
		
		$('#inspection_report_list').datagrid({'url':'/inspection_report_list/?id='+row.id});
		
		//初始化巡检报告tab面板
		$('#inspection_report_tabs').tabs('select',1);
		$('#inspection_report_tabs').tabs('select',2);		
		$('#inspection_report_tabs').tabs('select',3);		
		$('#inspection_report_tabs').tabs('select',4);	
		$('#inspection_report_tabs').tabs('select',5);	
		$('#inspection_report_tabs').tabs('select',6);	
		$('#inspection_report_tabs').tabs('select',0);
    }); 
	
	//清空数据
	function inspection_report_clear_data(){
		$('#inspection_report_state_list').datagrid('loadData', { total: 0, rows: [] }); 
		$('#inspection_report_tablespace_list').datagrid('loadData', { total: 0, rows: [] });   
		$('#inspection_report_role_list').datagrid('loadData', { total: 0, rows: [] });   
		$('#inspection_report_database_list').datagrid('loadData', { total: 0, rows: [] });   
		$('#inspection_report_table_list').datagrid('loadData', { total: 0, rows: [] }); 
		$('#inspection_report_foreign_table_list').datagrid('loadData', { total: 0, rows: [] }); 
		$('#inspection_report_index_list').datagrid('loadData', { total: 0, rows: [] }); 
	}
	
	//数据表属性初始化       
    $('#inspection_report_list').datagrid({
        'rownumbers':true,
        'singleSelect':true,
        'checkOnSelect':false,
        'selectOnCheck':false,
        'method':'post',
        'sortName':'createtime',
        'sortOrder':'desc',  
        'fitColumns':false,
        'multiSort':false,
        'remoteSort':true,
        'height':'100%',
        'width':'100%',
        'idField':'id',
        'onClickRow':function(rowIndex, rowData){       
            inspection_report_show();
        },
		'onLoadSuccess':function(data){
			var rows = $('#inspection_report_list').datagrid('getRows')
			if (rows.length>0){
				$('#inspection_report_list').datagrid('selectRow',0);
				inspection_report_show();
			}
		}
    });  
	
	//在右边显示巡检报告
	function inspection_report_show(){
		var row = $('#inspection_report_list').datagrid('getSelected');  
		if (!row){
			$.messager.alert('系统提示',"请选择要查看的巡检报告", 'warning');   
			return
		}
		//显示状态统计数据
		$('#inspection_report_state_list').datagrid({'url':'/inspection_report_state_list/?inspection_report_id='+row.id});
		//显示表空间
		$('#inspection_report_tablespace_list').datagrid({'url':'/inspection_report_tablespace_list/?inspection_report_id='+row.id});
		//显示角色
		$('#inspection_report_role_list').datagrid({'url':'/inspection_report_role_list/?inspection_report_id='+row.id});
		//显示数据库
		$('#inspection_report_database_list').datagrid({'url':'/inspection_report_database_list/?inspection_report_id='+row.id});
		//显示数据表
		$('#inspection_report_table_list').datagrid({'url':'/inspection_report_table_list/?inspection_report_id='+row.id});
		//显示外部表
		$('#inspection_report_foreign_table_list').datagrid({'url':'/inspection_report_foreign_table_list/?inspection_report_id='+row.id});
		//显示索引
		$('#inspection_report_index_list').datagrid({'url':'/inspection_report_index_list/?inspection_report_id='+row.id});
	}
	
	//设置右边显示巡检报告--状态表格的格式
	
	$('#inspection_report_state_list').datagrid({
        'rownumbers':true,
        'singleSelect':true,
        'checkOnSelect':false,
        'selectOnCheck':false,
        'method':'post',
        'sortName':'id',
        'sortOrder':'asc',  
        'fitColumns':false,
        'multiSort':false,
        'pagination':true,
        'remoteSort':true,
        'height':'100%',
        'width':'100%',
        'idField':'id',
        'pageSize':100,
        'pageList':[10,20,30,40,50,100,500,1000],
		'border':false
    });  
	
	//设置右边显示巡检报告--表空间表格的格式
	
	$('#inspection_report_tablespace_list').datagrid({
        'rownumbers':true,
        'singleSelect':true,
        'checkOnSelect':false,
        'selectOnCheck':false,
        'method':'post',
        'sortName':'spcname',
        'sortOrder':'asc',  
        'fitColumns':false,
        'multiSort':false,
        'pagination':true,
        'remoteSort':true,
        'height':'100%',
        'width':'100%',
        'idField':'id',
        'pageSize':100,
        'pageList':[10,20,30,40,50,100,500,1000],
		'border':false
    });  
	
	//设置右边显示巡检报告--角色表格的格式
	$('#inspection_report_role_list').datagrid({
        'rownumbers':true,
        'singleSelect':true,
        'checkOnSelect':false,
        'selectOnCheck':false,
        'method':'post',
        'sortName':'rolname',
        'sortOrder':'asc',  
        'fitColumns':false,
        'multiSort':false,
        'pagination':true,
        'remoteSort':true,
        'height':'100%',
        'width':'100%',
        'idField':'id',
        'pageSize':100,
        'pageList':[10,20,30,40,50,100,500,1000],
		'border':false
    });  
	
	//设置右边显示巡检报告--数据库表格的格式
	$('#inspection_report_database_list').datagrid({
        'rownumbers':true,
        'singleSelect':true,
        'checkOnSelect':false,
        'selectOnCheck':false,
        'method':'post',
        'sortName':'datname',
        'sortOrder':'asc',  
        'fitColumns':false,
        'multiSort':false,
        'pagination':true,
        'remoteSort':true,
        'height':'100%',
        'width':'100%',
        'idField':'id',
        'pageSize':100,
        'pageList':[10,20,30,40,50,100,500,1000],
		'border':false
    });  
	
	//设置右边显示巡检报告--数据表表格的格式
	$('#inspection_report_table_list').datagrid({
        'rownumbers':true,
        'singleSelect':true,
        'checkOnSelect':false,
        'selectOnCheck':false,
        'method':'post',
        'sortName':'datname',
        'sortOrder':'asc',  
        'fitColumns':false,
        'multiSort':false,
        'pagination':true,
        'remoteSort':true,
        'height':'100%',
        'width':'100%',
        'idField':'id',
        'pageSize':100,
        'pageList':[10,20,30,40,50,100,500,1000],
		'border':false
    });  
	
	//设置右边显示巡检报告--外部表表格的格式
	$('#inspection_report_foreign_table_list').datagrid({
        'rownumbers':true,
        'singleSelect':true,
        'checkOnSelect':false,
        'selectOnCheck':false,
        'method':'post',
        'sortName':'datname',
        'sortOrder':'asc',  
        'fitColumns':false,
        'multiSort':false,
        'pagination':true,
        'remoteSort':true,
        'height':'100%',
        'width':'100%',
        'idField':'id',
        'pageSize':100,
        'pageList':[10,20,30,40,50,100,500,1000],
		'border':false
    });  
	
	//设置右边显示巡检报告--索引表格的格式
	$('#inspection_report_index_list').datagrid({
        'rownumbers':true,
        'singleSelect':true,
        'checkOnSelect':false,
        'selectOnCheck':false,
        'method':'post',
        'sortName':'datname',
        'sortOrder':'asc',  
        'fitColumns':false,
        'multiSort':false,
        'pagination':true,
        'remoteSort':true,
        'height':'100%',
        'width':'100%',
        'idField':'id',
        'pageSize':100,
        'pageList':[10,20,30,40,50,100,500,1000],
		'border':false
    });  
	
	//创建巡检报告对话框
	$('#inspection_report_dialog_insert').bind('click', function(){
		var row = $('#dg').datagrid('getSelected');    
		if (!row)
            {
                $.messager.alert('系统提示',"请选择要创建的节点", 'warning');    
                return;
            } 
		$('#inspection_report_insert_dialog').dialog('open').dialog('center').dialog('setTitle','创建巡检报告');   
		$('#inspection_report_insert_dialog_form').form('clear'); 
		$.messager.progress(); 
		$.ajax({
                    type:"POST",
                    url:"/get_database_list/",
                    data:{id:row.id},
                    success:function(result){
                        $.messager.progress('close');   
                        if (result.return_code=="FAIL")                               
                            {                       
                                if ( result.show_login_dialog == 1)
                                    {   
										$('#inspection_report_insert_dialog').dialog('close'); 
                                        $('#login_dialog').dialog('open').dialog('center').dialog('setTitle','系统无法训别你的身份--操作员重新登录'); 
                                    }
                                else
                                    {
                                        $.messager.alert('错误提示',result.return_msg, 'error');   
                                    }
                            }
                        else
                            {
								result.unshift({ "datname": "", "dattext": "所有数据库" });  
                                $('#inspection_report_insert_database').combobox({data:result})
                            }  
                    },
                    dataType:"json"
               });  
		$('#inspection_report_insert_dialog_form').form('load',{'count_recordnum_processes':'0','count_system_obj':'不统计'});        
	});
	
	//创建巡检报告对话框－－确认创建按钮
    $('#inspection_report_insert_dialog_save').bind('click', function(){
		var row = $('#dg').datagrid('getSelected');    
		if (!row)
            {
                $.messager.alert('系统提示',"请选择要创建的节点", 'warning');    
                return;
            } 
        $('#inspection_report_insert_dialog_form').form('submit', {
            "url":'./inspection_report_make/', 
            onSubmit: function(param){
				param.id=row.id;
                var validate = $(this).form('validate'); 
                if ( validate ){
                    $.messager.progress();    
                    return true;
                }
                return false;
            },
            success: function(result){
                $.messager.progress('close');    
                var result = eval('('+result+')');  
                if (result.return_code=="FAIL")                               
                    {
                        if ( result.show_login_dialog == 1)
                            {   
                                $('#login_dialog').dialog('open').dialog('center').dialog('setTitle','系统无法训别你的身份--操作员重新登录'); 
                            }
                        else
                            {
                                $.messager.alert('错误提示',result.return_msg, 'error');            
                            }
                        
                    }   
                else
                    { 
						$.messager.alert('系统提示',result.return_msg, 'info');   
                        $('#inspection_report_list').datagrid('reload');   
						$('#inspection_report_insert_dialog').dialog('close');
                    }       
           }
        });   
    });  
	
	//创建巡检报告对话框－－取消按钮
    $('#inspection_report_insert_dialog_cancel').bind('click', function(){
        $('#inspection_report_insert_dialog').dialog('close');     
    });  
	
	//创建巡检报告
	function inspection_report_make(r){
		var row = $('#dg').datagrid('getSelected');    
		if (!row)
            {
                $.messager.alert('系统提示',"请选择要创建的节点", 'warning');    
                return;
            } 
		$.messager.progress(); 
		$.ajax({
                    type:"POST",
                    url:"/inspection_report_make/",
                    data:{id:row.id,report_name:r},
                    success:function(result){
                        $.messager.progress('close');   
                        if (result.return_code=="FAIL")                               
                            {                       
                                if ( result.show_login_dialog == 1)
                                    {   
                                        $('#login_dialog').dialog('open').dialog('center').dialog('setTitle','系统无法训别你的身份--操作员重新登录'); 
                                    }
                                else
                                    {
                                        $.messager.alert('错误提示',result.return_msg, 'error');   
                                    }
                            }
                        else
                            {
                                $.messager.alert('系统提示',result.return_msg, 'info');   
                                var row = $('#inspection_report_list').datagrid('reload');  
                            }  
                    },
                    dataType:"json"
               });  
	}
	
	//修改巡检报告
	$('#inspection_report_dialog_update').bind('click', function(){
		var row = $('#inspection_report_list').datagrid('getSelected');  
		if (!row){
			$.messager.alert('系统提示','请选择要修改的巡检报告', 'warning');   
			return
		}
		$.messager.prompt('修改巡检报告', '请填写新的巡检报告名称:', function(r){
			if (r){
				$.messager.progress(); 
				$.ajax({
		                    type:"POST",
		                    url:"/inspection_report_update/",
		                    data:{inspection_report_id:row.id,report_name:r},
		                    success:function(result){
		                        $.messager.progress('close');   
		                        if (result.return_code=="FAIL")                               
		                            {                       
		                                if ( result.show_login_dialog == 1)
		                                    {   
		                                        $('#login_dialog').dialog('open').dialog('center').dialog('setTitle','系统无法训别你的身份--操作员重新登录'); 
		                                    }
		                                else
		                                    {
		                                        $.messager.alert('错误提示',result.return_msg, 'error');   
		                                    }
		                            }
		                        else
		                            {
		                                $.messager.alert('系统提示',result.return_msg, 'info');   
										var index = $('#inspection_report_list').datagrid('getRowIndex', row)
		                        		$('#inspection_report_list').datagrid('updateRow',{'index':index , 'row' : {'report_name':r}});                   
		                            }  
		                    },
		                    dataType:"json"
		               });  
			}
		});
		
	});
	
	//删除巡检报告
	$('#inspection_report_dialog_delete').bind('click', function(){
		var row = $('#inspection_report_list').datagrid('getSelected');  
		if (!row){
			$.messager.alert('系统提示','请选择要删除的巡检报告', 'warning');   
			return
		}
		$.messager.confirm('删除巡检报告', '你确认要删除所选的巡检报告吗？', function(r){
			if (r){
				$.messager.progress(); 
				$.ajax({
		                    type:"POST",
		                    url:"/inspection_report_delete/",
		                    data:{inspection_report_id:row.id,report_name:r},
		                    success:function(result){
		                        $.messager.progress('close');   
		                        if (result.return_code=="FAIL")                               
		                            {                       
		                                if ( result.show_login_dialog == 1)
		                                    {   
		                                        $('#login_dialog').dialog('open').dialog('center').dialog('setTitle','系统无法训别你的身份--操作员重新登录'); 
		                                    }
		                                else
		                                    {
		                                        $.messager.alert('错误提示',result.return_msg, 'error');   
		                                    }
		                            }
		                        else
		                            {
		                                $.messager.alert('系统提示',result.return_msg, 'info');   
	                                    var index = $('#inspection_report_list').datagrid('getRowIndex',row);      
	                                    $('#inspection_report_list').datagrid('deleteRow',index);
										inspection_report_clear_data();
		                            }  
		                    },
		                    dataType:"json"
		               });  
			}
		});
		
	});
	
	
	//导出巡检报告数据
	$('#inspection_report_dialog_export').bind('click', function(){
		var row = $('#inspection_report_list').datagrid('getSelected');  
		if (!row){
			$.messager.alert('系统提示',"请选择要导出的巡检报告", 'warning');   
			return
		}
		$.messager.progress(); 
		$.ajax({
                    type:"POST",
                    url:"/inspection_report_export/",
                    data:{inspection_report_id:row.id},
                    success:function(result){
                        $.messager.progress('close');   
                        if (result.return_code=="FAIL")                               
                            {                       
                                if ( result.show_login_dialog == 1)
                                    {   
                                        $('#login_dialog').dialog('open').dialog('center').dialog('setTitle','系统无法训别你的身份--操作员重新登录'); 
                                    }
                                else
                                    {
                                        $.messager.alert('错误提示',result.return_msg, 'error');   
                                    }
                            }
                        else
                            {
								var downxls_obj = document.getElementById("downxls");  
				                downxls_obj.href=result.url;  
				                downxls_obj.download=result.filename;  
				                downxls_obj.click();  
                            }  
                    },
                    dataType:"json"
               });  
		//document.location.href="/inspection_report_export/?inspection_report_id="+row.id;
	});
	
	
	//巡检报表管理窗口－－取消按钮
    $('#inspection_report_dialog_cancel').bind('click', function(){
        $('#inspection_report_dialog').dialog('close');     
    });  	
	
	//打开进程管理窗口
    $('#cy_processadmin_click').bind('click', function(){    
	    var row = $('#dg').datagrid('getSelected');    
        if (!row)
            {
                var rows = $('#dg').datagrid('getChecked');  
                if (rows.length!=1)
                     {
                          $.messager.alert('系统提示',"请选择要查看的节点", 'warning');    
                          return;
                     }
                $('#dg').datagrid('selectRow',$('#dg').datagrid('getRowIndex',rows[0]));
                var row = $('#dg').datagrid('getSelected');      
            } 
        $('#processadmin_dialog').dialog('open').dialog('center').dialog('setTitle','进程管理－－'+row.node_name).dialog('refresh','processadmin.html'); 		
    }); 
	
	
	//打开表锁管理窗口
    $('#cy_lockadmin_click').bind('click', function(){    
	    var row = $('#dg').datagrid('getSelected');    
        if (!row)
            {
                var rows = $('#dg').datagrid('getChecked');  
                if (rows.length!=1)
                     {
                          $.messager.alert('系统提示',"请选择要查看的节点", 'warning');    
                          return;
                     }
                $('#dg').datagrid('selectRow',$('#dg').datagrid('getRowIndex',rows[0]));
                var row = $('#dg').datagrid('getSelected');      
            } 
        $('#lockadmin_dialog').dialog('open').dialog('center').dialog('setTitle','表锁管理－－'+row.node_name).dialog('refresh','lockadmin.html'); 		 		
    }); 
	
	//打开查询统计窗口
    $('#cy_querycount_click').bind('click', function(){    
	    var row = $('#dg').datagrid('getSelected');    
        if (!row)
            {
                var rows = $('#dg').datagrid('getChecked');  
                if (rows.length!=1)
                     {
                          $.messager.alert('系统提示',"请选择要查看的节点", 'warning');    
                          return;
                     }
                $('#dg').datagrid('selectRow',$('#dg').datagrid('getRowIndex',rows[0]));
                var row = $('#dg').datagrid('getSelected');      
            } 
        $('#querycount_dialog').dialog('open').dialog('center').dialog('setTitle','查询统计－－'+row.node_name).dialog('refresh','querycount.html');  		
    }); 
	
    
    //操作员修改登录密码
    $('#cy_password_click').bind('click', function(){      
        $('#password_update_dialog').dialog('open').dialog('center').dialog('setTitle','修改登录密码');  
        $('#password_update_dialog_form').form('clear'); 
    }); 
    
    //操作员修改密码
    $('#password_update').bind('click', function(){
        $('#old_password').passwordbox({"value":$('#old_password').passwordbox("getValue"),"required":true});  
        $('#new_password').passwordbox({"value":$('#new_password').passwordbox("getValue"),"required":true});
        $('#new_password_confirm').passwordbox({"value":$('#new_password_confirm').passwordbox("getValue"),"required":true});
        $('#password_update_dialog_form').form('submit', {
            "url":'./password_update/', 
            onSubmit: function(){
                var validate = $(this).form('validate'); 
                if ( validate ){
                    $.messager.progress();    
                    return true;
                }
                return false;
            },
            success: function(result){
                $.messager.progress('close');    
                var result = eval('('+result+')');  
                if (result.return_code=="FAIL")                               
                    {
                        if ( result.show_login_dialog == 1)
                            {   
                                $('#login_dialog').dialog('open').dialog('center').dialog('setTitle','系统无法训别你的身份--操作员重新登录'); 
                            }
                        else
                            {
                                $.messager.alert('错误提示',result.return_msg, 'error');            
                            }
                        
                    }   
                else
                    {   
                        $.messager.alert('系统提示',result.return_msg, 'info');        
                        $('#old_password').passwordbox({"value":"","required":false});            
                        $('#new_password').passwordbox({"value":"","required":false});
                        $('#new_password_confirm').passwordbox({"value":"","required":false});              
                        $('#password_update_dialog').dialog('close');
                    }       
           }
        });        
    });   
    
    //退出
    $('#cy_exit_click').bind('click', function(){  
        $.messager.confirm('退出确认','你确认要退出登录状态吗?', function(r){
            if (r)
                {    
                     $.messager.progress();   
                     $.ajax({
                         type:"POST",
                         url:"/exit/",
                         success:function(result){
                             $.messager.progress('close');   
                             if (result.return_code=="FAIL")                               
                                 {                       
                                     $.messager.alert('错误提示',result.return_msg, 'error');   
                                 }
                             else
                                 {
                                     //document.location.href="./index.html";
                                     $('#login_dialog').dialog('open').dialog('center').dialog('setTitle','你已经安全退出，想操作请重新登录');     
                                 }  
                         },
                         dataType:"json"
                     });      
                }
        });
    }); 
    
    //检查操作员是否登录
    $.ajax({
        url:"/logincheck/",
        success:function(result){
            if (result.return_code=="FAIL")                               
                {                       
                    $('#login_dialog').dialog('open').dialog('center').dialog('setTitle','操作员登录');   
                } 
        },
        dataType:"json"
    });  
    
     
});


function closes(){  
    $("#Loading").fadeOut("normal",function(){
        $(this).remove();        
    });     
}      
var pc;   
$.parser.onComplete = function(){ 
    if(pc) clearTimeout(pc);    
    pc = setTimeout(closes, 500);
} 

//删除备份或者模板文件
function parameter_files_bak_template_delete(category,id,rowindex){
	if (category == "bak"){
		var g = $('#parameter_files_bak').combogrid('grid');
	} else {
		var g = $('#parameter_files_template').combogrid('grid');
	}
	$.ajax({        
	            type:"POST",
	            url:"/parameter_files_bak_template_delete/",
	            data:{'id':id},
	            success:function(result){
	                if (category == "bak"){
						$('#parameter_files_bak').combogrid('clear');
					}else{
						$('#parameter_files_template').combogrid('clear');
					}   
					$.messager.progress('close'); 
	                if (result.return_code=="FAIL")                               
	                    {                       
	                        if ( result.show_login_dialog == 1)
	                            {   
									$('#parameter_dialog').dialog('close');
	                                $('#login_dialog').dialog('open').dialog('center').dialog('setTitle','系统无法训别你的身份--操作员重新登录'); 
	                            }
	                        else
	                            {
	                                $.messager.alert('错误提示',result.return_msg, 'error');   
	                            }
	                    }
	                else
	                    {      
							$.messager.alert('系统提示','删除成功', 'info'); 
							g.datagrid('deleteRow',rowindex);
	                    }
	            },
	            dataType:"json"
           }); 
}

//参数配置管理-获取历史文件内容
function parameter_files_bak_template_load(category,id,rowindex) {
    if ($('#parameter_id').textbox('getValue') == "") return ;
    $.messager.progress();   
    $('#parameter_file_contents').textbox('setValue',"数据加载中...");
    $.ajax({        
	            type:"POST",
	            url:"/parameter_get_bak_template_contents/",
	            data:{'id':id},
	            success:function(result){
	                $.messager.progress('close');   
	                if (result.return_code=="FAIL")                               
	                    {                       
	                        if ( result.show_login_dialog == 1)
	                            {   
									$('#parameter_dialog').dialog('close');
	                                $('#login_dialog').dialog('open').dialog('center').dialog('setTitle','系统无法训别你的身份--操作员重新登录'); 
	                            }
	                        else
	                            {
	                                $.messager.alert('错误提示',result.return_msg, 'error');   
	                            }
	                    }
	                else
	                    {      
							s = result.parameter_file_conetens;
							s = s.substring(0,s.length-1);
				            $('#parameter_file_contents').textbox('setValue',s);  
		                }  
	            },
	            dataType:"json"
        });      
}

</script>
</body>
</html>